The npm command not found error js server, which you can download from the nodejs.org website. Once you downloaded and installed Node. js, open the terminal and run the npm -v command. Once you see the npm version, you should be able to run the npm install command again.
Any global installs will cache packages to /root/. npm instead of root -owned files at /home/me/. npm . Just always use sudo -i or sudo -H when running npm install to install global packages and your npm permissions problems will melt away.
On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.
I had to do
sudo apt-get install npm
that worked for me.
The npm file should be in /usr/local/bin/npm
. If it's not there, install node.js again with the package on their website. This worked in my case.
For MAC users, the follow steps worked for me.
If you get Error for Brew, Here's the command you need to type first in the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
$ brew update
$ brew uninstall node
$ brew install node
$ brew postinstall
I had the same problem; here are the commands to fix it:
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
WARNING! - Doing a chmod 777
is a fairly radical solution. Try these first, one at a time, and stop when one works:
$ sudo chmod -R 777 /usr/local/lib/node_modules/npm
$ sudo chmod -R 777 /usr/local/lib/node_modules
$ sudo chmod g+w /usr/local/lib
$ sudo chmod g+rwx /usr/local/lib
$ brew postinstall node
is the only install part where I would get a problem
Permission denied - /usr/local/lib/node_modules/npm/.github
So I
// !! READ EDIT ABOVE BEFORE RUNNING THIS CODE !!
$ sudo chmod -R 777 /usr/local/lib
$ brew postinstall node
and viola, npm is now linked
$ npm -v
3.10.10
Extra
If you used -R 777
on lib my recommendation would be to set nested files and directories to a default setting:
find /usr/local/lib -type f -print -exec chmod 644 {} \;
find /usr/local/lib -type d -print -exec chmod 755 {} \;
chmod /usr/local/lib 755
I had to do the following:
brew update
brew uninstall node
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With