Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM not found when using NVM

Tags:

node.js

npm

nvm

I have installed node/npm using the nvm documentation.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash

Then:

nvm install node

At this point node is working but the npm command result with:

npm: command not found

How can I have npm to work correctly ?

like image 652
Raphaël Avatar asked Nov 23 '15 14:11

Raphaël


People also ask

How do I fix npm not found error?

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.

Is npm included in NVM?

nvm installs Node which installs npm. If you don't need/want to switch between Node versions then you don't probably don't need nvm.

Does NVM install node install npm?

We strongly recommend using a Node version manager like nvm to install Node. js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.


Video Answer


3 Answers

I found out that this was a conflict with a previous versions of npm that have not been removed properly despite a apt-get remove node.

I solved it by reinstalling npm from scratch:

rm -R ~/.npm ~/.nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
nvm install node

I found the solution here.

like image 59
Raphaël Avatar answered Oct 10 '22 11:10

Raphaël


If you run NVM-Windows, don't forget to run nvm on. (this solve the problem as title for me.)

like image 22
Rainning Avatar answered Oct 10 '22 11:10

Rainning


I fixed this by doing this command:

$ command -v npm

and then reopen the shell window.

like image 44
Heartbit Avatar answered Oct 10 '22 10:10

Heartbit