Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can no longer use npm command after trying to update

Tags:

node.js

yeoman

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  [email protected] { [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.

like image 941
user2483724 Avatar asked Feb 28 '14 17:02

user2483724


People also ask

Why my npm command is not working?

Windows Manually Add Node and NPM to Path On Windows, you may face the “npm command not found” error if the path to nodejs and npm are not added to your path variable. To fix this, locate the path to nodejs and npm binaries. The command above should add the specified directory to the path variable.

How do I update npm to latest version?

Go into %ProgramFiles%\nodejs\node_modules\npm and copy the file named npmrc in the new npm folder, which should be %appdata%\npm\node_modules\npm . This will tell the new npm where the global installed packages are.

How do I uninstall npm and reinstall again?

go to /usr/local/include and delete any node and node_modules directory. if you installed with brew install node, then run brew uninstall node in your terminal. check your Home directory for any local or lib or include folders, and delete any node or node_modules from there.


2 Answers

I installed using brew after: brew install node

sudo brew postinstall node
like image 171
bahek2462774 Avatar answered Oct 13 '22 00:10

bahek2462774


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

like image 45
user2483724 Avatar answered Oct 13 '22 01:10

user2483724