Reputation: 14216
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.
Upvotes: 1
Views: 452
Reputation: 1959
you can own the directory that npm is trying to install to, I too disliked having to sudo
. In fact, NPM states that you shouldn't sudo as well.
try:
sudo chown -R `whoami` /Users/Lynda/npm-global/lib/node_modules
remember that this will bind it to your current user, whoami
is a bash variable to get your user name.
Upvotes: 2
Reputation: 8503
If you would like to avoid sudo'ing, I recommend you use a version manager for node such as nvm. This allows to install global packages without sudo and also to run different versions of node and/or io.js side by side.
Upvotes: 1
Reputation: 17753
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
Upvotes: 2
Reputation: 2509
As this line
npm ERR! Please try running this command again as root/Administrator
states, you need to have admin credentials to install the yeoman. So you can try with sudo npm install -g yo
Upvotes: 0
Reputation: 2197
If you see this:
npm ERR! Please try running this command again as root/Administrator.
Then sudo is probably exactly what you need to use. Try sudo npm install -g yo
Upvotes: 0