Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
966 views
in Technique[技术] by (71.8m points)

node.js - NPM and NODE command not found when using NVM

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...