NPM not found when using NVM

一曲冷凌霜 提交于 2019-12-19 05:07:20

问题


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 ?


回答1:


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.




回答2:


I fixed this by doing this command:

$ command -v npm

and then reopen the shell window.




回答3:


This problem especially happens in windows which happens because of missing admin rights for cmd.

If you are using Git bash

  1. Go in installation directory e.g C:\Program Files\Git
  2. Right click properties -> compatibility.
  3. Tick the checkbox with label -> Run as administrator.
  4. Run the git bash again & execute npm list and then npm use 'version_to_be_used'

Same goes for Cmd




回答4:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!