2

I have a problem installing the LTS version of node.

When I do "node -v", it says :

v7.4.0 

But when I do "nodejs -v", it says :

v4.2.6 

Furthermore, the installation of node does not automatically install npm.

I also meet many problems on my project with nodejs.

Thanks.

Edit : I resolve the problem by reinstalling my Ubuntu and save my data in a another partition then do the method given by Nodejs website, works fine.

3 Answers 3

2

This is a common problem on UNIX systems as older versions of NodeJS were used using the nodejs command.

To avoid this, I would recommend using the Node Version Manager that makes using the desired version of NodeJS much easier.

Sign up to request clarification or add additional context in comments.

Comments

0

The easiest and the most manageable way is to use Node Version Manager.

The way I did it when I had the same problem was to download the tar archive from the official website https://nodejs.org/en/. Then you can extract the files with

tar -xJf node-v6.9.*-linux-tar.xz 

The folder will contain 4 folders bin include lib share. For your convenience you can copy the contents of these directories in the respective /usr/local/ folder.

Comments

0

display the offending ubuntu package issue this in a terminal

dpkg -l | grep nodejs 

to remove nodejs issue

sudo apt-get remove --purge nodejs 

Now you are left with your node v7.4.0
... the most typical way to install node does give you its matching npm ... personally I compile the source code and issue all npm install commands as myself not using sudo for anything node related

You say LTS which currently is v6.9.5 yet you have the latest version v7.4.0 so lets also remove it ... issue this to see where it lives

type node 

... my output says

node is hashed (/home/stens/node-v7.5.0/bin/node) # YMMV 

to remove that release just zap its dir

rm -r /home/stens/node-v7.5.0 

Done - now we are starting from a clean slate

Depending on what you want the easy instructions are at https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

... to give yourself node LTS issue

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs # this will mean issue npm as sudo going forward 

lets verify what version we have

stens@bodhisattva ~ $ node --version v6.9.5 stens@bodhisattva ~ $ nodejs --version v6.9.5 stens@bodhisattva ~ $ npm --version 3.10.10 

Boom ;-)

3 Comments

Thanks, but I meet a problem, the nodejs doesn't install, node yes but not nodejs.
Once installed always execute by calling ... node ... not ... nodejs
Ouf,I succedded, I reinstall my Ubuntu then just do the method given by the nodejs website, works fine.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.