Npm install, bower install permission issues (roots 7.0)

I followed all of the instructions for activation the new roots 7 here: http://roots.io/roots-101/#theme-activation

I got as far as typing ‘npm install’ and got the following:

$ npm install

roots@7.0.0 postinstall /var/www/example.dev/web/app/themes/roots
node_modules/.bin/bower install

sh: 1: node_modules/.bin/bower: Permission denied
npm ERR! weird error 126
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! not ok code 0

After which I tried running the following:

$ ./node_modules/.bin/bower install

-bash: ./node_modules/.bin/bower: Permission denied


$ sudo ./node_modules/.bin/bower install

/usr/bin/env: node: No such file or directory


I want to persevere because I love using roots but every new version introduces so many teething issues for me :frowning:. Anyone encountered this or able to suggest a solution?

I already tried doing sudo npm install -g bower, which executes without errors as far as I can tell, still doesn’t let me run npm install.

Cheers :slight_smile:

Can you try this?

$ npm install -g bower

npm http GET https://registry.npmjs.org/bower
npm http 304 https://registry.npmjs.org/bower
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/bin/bower’
npm ERR! error rolling back bower@1.3.7 { [Error: EACCES, unlink ‘/usr/local/bin/bower’] errno: 3, code: ‘EACCES’, path: ‘/usr/local/bin/bower’ }
npm ERR! Error: EACCES, unlink '/usr/local/bin/bower’
npm ERR! { [Error: EACCES, unlink ‘/usr/local/bin/bower’] errno: 3, code: ‘EACCES’, path: ‘/usr/local/bin/bower’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.13.0-24-generic
npm ERR! command “/usr/bin/nodejs” “/usr/bin/npm” “install” “-g” "bower"
npm ERR! cwd /var/www/example.dev/web/app/themes/roots
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /usr/local/bin/bower
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/usr/local/bin/bower’
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/www/example.dev/web/app/themes/roots/npm-debug.log
npm ERR! not ok code 0

Tried it and it gave the above response, I’m out of my depth here! Should probably mention I’m on a Ubuntu 14/Nginx Vagrant VM ceated using the puphpet website.

sudo npm install -g bower

When you installed globally with -g you need root permissions.

As I mentioned above in the first post I already tried sudo npm install -g bower which executed with no errors, however npm install gives the error pasted in my first post.

trying sudo npm install gives this:

$ sudo npm install
npm WARN cannot run in wd roots@7.0.0 node_modules/.bin/bower install (wd=/var/www/example.dev/web/app/themes/roots)

Which seemed like it had completed just with a warning, but then trying grunt watch or sudo grunt watch both give:

/usr/bin/env: node: No such file or directory

Not sure what else to try…

I suggest deleting the entire node_modules dir and starting over. Should probably make sure you have a relatively recent version of Node as well in case there’s been npm bugs fixed.

  1. Make sure Node is installed (which is done)
  2. sudo npm install -g grunt-cli
  3. sudo npm install -g bower
  4. In roots dir: npm install --ignore-scripts
  5. In roots dir: bower install

There may be some issue with the postinstall script in your first post, so using --ignore-scripts will skip it then you run bower install manually.

I’ve been working on a different project on a similar VM today (Apache instead of Nginx) and using the steps above led to a similar problem.

npm install --ignore-scripts outputs a lot of http requests and then:

roots@7.0.0 postinstall /var/www/web/app/themes/roots-master
node_modules/.bin/bower install

sh: 1: node_modules/.bin/bower: Permission denied
npm ERR! weird error 126
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! not ok code 0

So seems as if --ignore-scripts didn’t work and there appears to be an unexplained problem with ‘legacy binary’ version of node?

The ‘weird error 126’ doesn’t help much!

Really need to try it on the original VM in question and let you know if it sorted anything, but I’m beginning to doubt it will.

Both are Ubuntu 14 Vagrant VMs generated with puphpet (if you’re familiar I could even attach a config.yaml for puphpet if it helps) and node was installed by running sudo apt-get install npm and letting apt figure out the dependencies… so I assume it’s just the latest one from the Ubuntu repos.

Would that potentially cause an issue?

Reading this made me think it could be the legacy Node version from standard Ubuntu repos.

Attempted:

sudo apt-get remove nodejs npm
sudo apt-get install nodejs
sudo apt-get install npm

To see if it would give me the latest one:

$ nodejs -v
v0.10.25

But exactly the same fail/error happens when I try npm install.

I think “weird error 126” must be the problem! If you google “weird error 126” this thread is on the top page of results which makes me think it can’t be very common…?

No closer to understanding much of this, but the following worked for me (if anyone else has this issue)…

  1. Re-ran the steps in @swalkinshaw’s post above:
  1. Make sure Node is installed (which is done)
  2. sudo npm install -g grunt-cli
  3. sudo npm install -g bower
  4. In roots dir: npm install --ignore-scripts
  5. In roots dir: bower install

There are errors at step 4, but I just ignored them. Ran bower install, which complained but still completed. Then rant grunt and got “/usr/bin/env: node: No such file or directory”.

After some more headaches, I ran which nodejs ("/usr/bin/nodejs" for me). Then put a simlink to that in the place where grunt was looking.

sudo ln -s /usr/bin/nodejs /usr/bin/node

Now grunt works as it should I think! Not really sure if what I’m doing is ideal.

@mikesource Hi. Did you get to the bottom of this? I think I’m hitting the same issue. If I try ‘grunt watch’ or ‘grunt dev’, I get:

grunt watch
grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started

or you can just install node-legacy using this commans sudo apt-get install nodejs-legacy to avoid the node relatesd issues.