可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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
- 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