NPM and NODE command not found when using NVM

10.6k views Asked by At

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.

2

There are 2 answers

1
rsp On

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
0
Maheshvirus On

Edit .bash_profile using the below command.

nano .bash_profile

And add the following lines to .bash_profile

export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh

Save it. Exit the terminal and check the magic.