4

i am trying to install yeoman on my server but for some reason do i keep getting a permission denied error.

$npm install -g yo
/root/.node/bin/yo -> /root/.node/lib/node_modules/yo/cli.js

> yo@1.3.3 postinstall /root/.node/lib/node_modules/yo
> yodoctor

sh: 1: yodoctor: Permission denied

npm ERR! yo@1.3.3 postinstall: `yodoctor`
npm ERR! Exit status 127
npm ERR! 
npm ERR! Failed at the yo@1.3.3 postinstall script.
npm ERR! This is most likely a problem with the yo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     yodoctor
npm ERR! You can get their info via:
npm ERR!     npm owner ls yo
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.13.0-37-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "yo"
npm ERR! cwd /root
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

i have tried to reinstall ubuntu (14.04) but nothing works.

Ajeo
  • 63
  • 1
  • 1
  • 4

4 Answers4

11

I think Shantaru is right, you need to do it with sudo.

Try this

sudo npm uninstall -g yo
sudo npm cache clean
sudo npm install -g yo

I have a similar problem weeks ago and that works.

Edit: If that didn't work, do this before:

npm config set unsafe-perm true
Kangcor
  • 1,179
  • 1
  • 16
  • 26
  • try this: npm install -g yo@1.3.2 – Kangcor Nov 19 '14 at 11:51
  • 3
    weird... please try to set: npm config set unsafe-perm true – Kangcor Nov 19 '14 at 12:31
  • Glad to read that! But i think that's not a right solution, only a temporal workaround. Something is wrong with your users and permissions... try to delete everything about node and do a fresh install in the recommended ways when you want to do another try. Good luck! – Kangcor Nov 19 '14 at 12:40
  • `npm config set unsafe-perm true` fixed the issue for me as well. I am installing yo as root on a server using `npm install -g yo`. – MangoHands Mar 22 '15 at 03:32
  • Thanks, i add the set unsafe-perm in the answer for future visitors. – Kangcor Mar 22 '15 at 09:45
1

You need to have root permission to install this so try "sudo npm install -g yo" instead of "npm install -g yo"

Shantanu
  • 2,206
  • 18
  • 16
1

I had the same issue and tried running the install using 'sudo npm install -g yo' but it still failed. I couldn't get away from the fact that the error message still said 'sh: 1: yodoctor: Permission denied', indicating a permissions issue. I therefore tried completely changing to the root user using 'sudo su' and THEN running 'npm install -g yo'. This worked for me.

If, like me, when running the install that way you encounter other errors, it could be because you need to upgrade npm first (run 'npm install -g npm' to do that). It could also be because you have yo partially installed from your previous attempts and that's causing issues. Therefore you can try removing it first using 'npm remove -g yo' (still as root user) and then installing it again using 'npm install -g yo'.

Hope this helps someone out there.

0

To avoid permission errors, install node with nvm.

See the detailed solution here: npm install g less does not work

gazdagergo
  • 6,187
  • 1
  • 31
  • 45