5

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
schlow
  • 155
  • 1
  • 2
  • 11
  • You shouldn't need to use `curl` to install NPM. That was how it was installed for Node 0.4, but it's been [bundled with Node](https://npmjs.org/doc/README.html) since [0.6.3](http://blog.nodejs.org/2011/11/25/node-v0-6-3/). And, it seems you already have it installed -- `npm ERR! npm -v 1.1.71`. Try `npm -v` and `npm -h`. – Jonathan Lonowski Sep 20 '13 at 18:49
  • That's what I thought but when I do that, I get `-bash: npm: command not found` and this is right after doing a `brew install node`, so it should be the latest version – schlow Sep 20 '13 at 19:34
  • @JonathanLonowski so I reinstalled node with brew and `npm -v` gives me 1.2.10 but then outputs `Segmentation fault: 11` do you know what that could be? – schlow Sep 20 '13 at 19:49

5 Answers5

18

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
Community
  • 1
  • 1
jolyonruss
  • 1,770
  • 2
  • 19
  • 34
6

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.

5

Try clearing npm cache with

npm cache clean

Hope that helps.

when all else fails, clear you cache

leesei
  • 6,020
  • 2
  • 29
  • 51
2

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..

gstroup
  • 1,064
  • 8
  • 16
  • 1
    It works with sudo but I don't feel very comfortable doing it that way. From what I understand, it shouldn't be necessary, right? – schlow Sep 20 '13 at 19:54
  • I would recommend you uninstall node completely, then try to reinstall with the latest .pkg file. It's easier than installing with home brew. This will give you nom in the bundle with node. – gstroup Sep 20 '13 at 21:46
0

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...

shmuli
  • 5,086
  • 4
  • 32
  • 64