NPM and NODE command not found when using NVM

半世苍凉 提交于 2019-11-28 10:43:47

问题


Seen other questions, but I think they are not my case.

I think the problem is over here, but I don't know how to solve it:

I do have latest Node version installed (I followed the official github page instructions)

> nvm install v7.3.0
v7.3.0 is already installed.
Now using node v7.3.0

I check node and npm versions installed

> which node
~/.nvm/versions/node/v7.3.0/bin/node

> which npm
~/.nvm/versions/node/v7.3.0/bin/npm

I check the PATH is right and it actually is

> echo $PATH
~/.nvm/versions/node/v7.3.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

But it still fails and when I browse through nvm folders... I find this, which I don't know how to change or solve:

> ls -a .nvm/versions/node
.
..
.DS_Store
v6.4.0 // WTF???

And I promise I didn't do anything, I mean... this is a clean install, .nvm folder didn't exist before installing nvm.


回答1:


If you want to install the version you want in the place you want then you can follow my tutorial here on GitHub:

  • https://gist.github.com/rsp/edf756a05b10f25ee305cc98a161876a

It's about version 6.7.0 but you can change it to any other version. It show you how to install either from source or from binary packages and following that tutorial you will always know which version is where, because you have full control over the installation instead of relying on tools that do that automatically for you.

If you want to have Node 7.3.0 in /usr/local for example the it is just:

wget https://nodejs.org/dist/v7.3.0/node-v7.3.0.tar.gz
tar xzvf node-v7.3.0.tar.gz
cd node-v7.3.0
./configure --prefix=/usr/local
make && make test && echo OK || echo ERROR
sudo make install


来源:https://stackoverflow.com/questions/41396941/npm-and-node-command-not-found-when-using-nvm

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