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 ?
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.
I fixed this by doing this command:
$ command -v npm
and then reopen the shell window.
This problem especially happens in windows which happens because of missing admin rights for cmd.
If you are using Git bash
- Go in installation directory e.g C:\Program Files\Git
- Right click properties -> compatibility.
- Tick the checkbox with label -> Run as administrator.
- Run the git bash again & execute npm list and then npm use 'version_to_be_used'
Same goes for Cmd
Install node using node source distribution:
curl -sL https://deb.nodesource.com/setup_[version].x | bash -
apt-get install -y nodejs
[version] = the wanted version. See the repository to choose the correct: NodeSource Node.js Binary Distributions
来源:https://stackoverflow.com/questions/33874049/npm-not-found-when-using-nvm