Ricky ponting
Ricky ponting

Reputation: 4857

node -v and nodejs -v shows different versions

node -v and nodejs -v shows different versions

My node -v shows 4.2 version and nodejs -v shows 6.10.3

So what should be the issue? I want node -v to show 6.10.3.

Upvotes: 0

Views: 1310

Answers (3)

ponury-kostek
ponury-kostek

Reputation: 8060

I think you have installed both nodejs and nodejs-legacy packages. So just remove one of them. nodejs-legacy is v.4.x and nodejs is v.6.x

apt-get remove nodejs-legacy

If it says there is no "nodejs-legacy" try

sudo apt-get remove nodejs

And you will see it in the list when it asks you if you are sure about uninstalling.

Upvotes: 0

Jay Suchak
Jay Suchak

Reputation: 172

i also face this problem

i tried this

1) sudo apt-get remove nodejs sudo apt-get remove npm

remove cache from /etc/apt/sources.list.d

2)sudo apt-get update

then install again nodejs

3)sudo apt install nodejs

Upvotes: 1

Anand S
Anand S

Reputation: 820

I also had the same problem, and I solved this by doing the following steps.

Step 1: completely remove node and node js from system

sudo apt-get remove nodejs sudo apt-get remove npm

Then go to /etc/apt/sources.list.d and remove any node list if you have. Then update system cache by running

sudo apt-get update

Step2: Installing Specific version of node (I am using node version 8)

curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
sudo apt install nodejs

Now If you see node -v and nodejs -v, you get both the versions are same as

v8.14.0

Upvotes: 3

Related Questions