ajmajmajma ajmajmajma - 29 days ago 11
Node.js Question

permissions installing yeoman with npm - eaccess?

I installed npm with homebrew and had to link it - i'm thinking this may be some part of the issue. This is all new to me so I am seeking any help. I am trying to install yeoman and some other things on a computer with

npm install -g yo


however it is spitting back the error -

npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "yo"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! path /Users/Lynda/npm-global/lib/node_modules/yo/lib
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/Lynda/npm-global/lib/node_modules/yo/lib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/Users/Lynda/npm-global/lib/node_modules/yo/lib' }


I did a bunch of googling and can't find anything, could use some help! I'd like to avoid sudo'ing if I can. Thanks.

Answer

My preferred way of installing node & npm on OSX:

Install node via homebrew without npm:

brew update
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc

Then install npm via the install script on npmjs.org:

If you're wild and crazy:

curl -L https://www.npmjs.org/install.sh | sh

Otherwise, download https://www.npmjs.org/install.sh, inspect to your satisfaction, chmod +x and execute it.

Then add $HOME/.node/bin to your path.

Note: If you've previuously installed node + npm via the graphical installer or homebrew, you'll want to remove the previous install before installing again. For instance, if you installed via the graphical installer:

rm -rf /usr/local/lib/node_modules
rm -rf /usr/local/include/node
rm -rf ~/.npm
mv ~/.npmrc ~/.npmrc-old
Comments