schlow
schlow

Reputation: 154

NPM install fails

I am currently unable to install NPM on Mac OS, I have looked all over the place for someone with the same error, but I can't seem to find any. Could anyone give me a hand? This is what I get after running the curl command to install NPM:

All clean!
npm-install-94139.sh: line 302: 94407 Segmentation fault: 11  "$node" cli.js rm npm -gf
npm ERR! addLocal Could not install .
npm ERR! Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock'
npm ERR!  { [Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.5.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package
npm ERR! node -v v0.8.19
npm ERR! npm -v 1.1.71
npm ERR! path /Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package/npm-debug.log
npm ERR! not ok code 0
It failed

Upvotes: 5

Views: 19477

Answers (5)

jolyonruss
jolyonruss

Reputation: 1840

The solution on this other question seems better than messing around with NVM - npm throws error without sudo

SOLUTION: You need to unlock permissions in home directory, like Noah says.

sudo chown -R `whoami` ~/.npm

You also need to write it to your library as well, like Xilo says.

sudo chown -R `whoami` /usr/local/lib/node_modules

Upvotes: 18

shmuli
shmuli

Reputation: 5192

From the NPM readme file: https://npmjs.org/doc/README.html

SUPER EASY INSTALL

npm comes with node now.

Windows Computers

Get the MSI. npm is in it.

Apple Macintosh Computers

Get the pkg. npm is in it.

Other Sorts of Unices

Run make install. npm will be installed with node.

If you want a more fancy pants install (a different version, customized paths, etc.) then read on...

Upvotes: 0

leesei
leesei

Reputation: 6070

Try clearing npm cache with

npm cache clean

Hope that helps.

when all else fails, clear you cache

Upvotes: 5

user2801430
user2801430

Reputation: 84

My guess is that a directory used by npm (maybe /usr/local or something in your home folder) has the wrong permissions. Installing with sudo might work now but it can also bite you later since you'll definitely create files and directories as root, possibly causing problems later when npm tries to cache things.

My advice would be to uninstall, then reinstall via nvm instead. This does a great job of managing different node versions under ~/.nvm without having to use sudo.

Upvotes: 6

gstroup
gstroup

Reputation: 1064

Did you try "sudo" with your curl command? Also, if you install a new version of Node, it now includes NPM, so you don't have to even install NPM separately..

Upvotes: 2

Related Questions