17

I was trying to install yeoman but it threw an error regarding self signed certificates.

I looked this up and I found out I had to upgrade node.

Upgrading node however threw this: (forgot to use sudo with it...)

npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! error rolling back  npm@1.4.4 { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']

After this I couldn't use npm anymore. It couldn't be found:

/usr/local/bin/npm: No such file or directory

Trying to reinstall with brew:

It appears you already have npm installed at /usr/local/lib/node_modules/npm

Tells me to npm uninstall but I can't use npm anymore.

The error message is more detailed but I think the part about "unlinking" is the main thing. How do I go about linking it back up and also why was such a weird error thrown?

EDIT: also ran npm config set ca "" before trying to update node.

user2483724
  • 2,011
  • 4
  • 22
  • 41

3 Answers3

27

I installed using brew after: brew install node

sudo brew postinstall node
bahek2462774
  • 642
  • 6
  • 12
9

Found some links with similar errors and all with different solutions:

https://github.com/npm/npm/issues/4099

Error: The 'brew link' step did not complete successfully

How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

The answer for the third one helped most I think, specifically:

go to /usr/local/lib and delete any node and node_modules

Community
  • 1
  • 1
user2483724
  • 2,011
  • 4
  • 22
  • 41
2

sudo brew postinstall command works for me. This issue is caused if you try to update a core NPM package without using the sudo command

learn2reid
  • 170
  • 1
  • 4