Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic installation issue for gruntjs - for use with Bootstrap

Apologies for the vague title - wasn't sure how else to word it.

Basically, I am having problems with grunt. A few weeks ago I installed Bootstrap sourcecode as well as Grunt. Everything was working fine when I ran grunt, my LESS compiled to CSS.

I came back to the same installation a few days ago and Grunt was not performing. It isn't even trying to compile any LESS files and I was met with messages about Grunt being missing and/or unmet dependencies (despite my NPM and nodejs being up to date on both my user account and root). I didn't think much to it and decided to reinstall grunt but to no avail.

Right now I have just deleted my bootstrap directory entirely under public_html. I then cloned from Github. I checked the cloned repo and it all looks good, it even includes a folder called 'grunt' with the Gruntfile.js beneath it. I assume this has come from the Git clone, which is very useful but ultimately, it's still not working.

I run grunt and am met with...

module.js:340
throw err;
      ^
Error: Cannot find module 'coffee-script'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous>(/var/www/andrewtanner.me/public_html/bootstrap/node_modules/grunt/lib/grunt.js:16:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

I then run npm install to attempt the installation of correct dependencies based on package.json but am met with...

npm WARN prefer global [email protected] should be installed with -g
npm WARN unmet dependency /var/www/andrewtanner.me/public_html/bootstrap/node_modules/grunt/node_modules/findup-sync requires glob@'~3.2.9' but will load
npm WARN unmet dependency /var/www/andrewtanner.me/public_html/bootstrap/node_modules/grunt/node_modules/glob,
npm WARN unmet dependency which is version 3.1.21
npm WARN unmet dependency /var/www/andrewtanner.me/public_html/bootstrap/node_modules/grunt/node_modules/findup-sync requires lodash@'~2.4.1' but will load

(I have truncated this to save scrolling)

I am at a total loss here. I am running npm 1.4.6 and nodejs 0.10.26 so I don't know wht Grunt won't run, especially considering I've had it running previously with no problems.

Update: I am now working on Ubuntu 14.04 (previously 12.04) and am receiving this message when running npm install. The errors above are no longer appearing but the common theme is that Grunt is still not installing/working.

[email protected] install /var/www/dev.andrewtanner.me/public_html/bootstrap/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs node install.js sh: 1: node: not found npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian npm ERR! weird error 127 npm ERR! not ok code 0

Why is this being more complicated than it needs to be?

Any help would be much appreciated - thank you.

like image 772
Andrew David Tanner Avatar asked Dec 20 '22 15:12

Andrew David Tanner


1 Answers

I had the very same issue with Ubuntu 14.04 and Bootstrap 3.2.0. In my case the problem has been resolved by installing the node.js compatibility package:

sudo apt-get install nodejs-legacy

Afterwards I ran npm install again, and it worked.

NOTE:

Don't forget to delete the node_modules folder before running npm install again, as the previously failed install may have left it in an inconsistent state.

I had errors on running grunt dist like this:

Loading Gruntfile.js...^^^ERROR
Error: Cannot find module 'error/validation'

Deleting the node_modules folder and running npm install again has resolved them.

like image 131
Attila Fulop Avatar answered Dec 22 '22 07:12

Attila Fulop