NPM not found when using NVM

匿名 (未验证) 提交于 2019-12-03 02:30:02

问题:

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 verions 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 rm -R ~/.nvm curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/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



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