3

I have an issue on my Ubuntu VM. I have tried several methods of updating to the latest Nodejs version (both LTS and Current), but running node --version still shows v4.8.4.

I have tried using both n and nvm to update, as well as manually downloading and building. No matter what, v4.8.4 seems to be the only version running.

If I run which node I get ~/.nvm/versions/node/v8.2.1/bin/node. This looks correct, but node --version is still v4.8.4.

How can I fix this?

Noahm888
  • 113
  • 1
  • 1
  • 10
  • dupe question https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version – Scott Stensland Sep 25 '17 at 20:19
  • Thank you @ScottStensland! That askubuntu link solved my problem. I needed to run `sudo ln -sf ~/.nvm/versions/node/v8.5.0/bin/node /usr/bin/nodejs` – Noahm888 Sep 26 '17 at 16:56

6 Answers6

4
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

sudo apt-get install -y nodejs

Only this one is working the rest of the methods are not useful for the node

Itchydon
  • 2,572
  • 6
  • 19
  • 33
3

Thank you everyone for trying to help. The link @ScottStensland provided above (https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version) solved the issue for me. I needed a link!

sudo ln -sf ~/.nvm/versions/node/v8.5.0/bin/node /usr/bin/nodejs

Noahm888
  • 113
  • 1
  • 1
  • 10
2

In Ubuntu 16.04 its works:

Edit or create the file :nodesource.list

sudo gedit /etc/apt/sources.list.d/nodesource.list

Insert this text:

deb https://deb.nodesource.com/node_10.x bionic main

deb-src https://deb.nodesource.com/node_10.x bionic main

Run these commands:

curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -


sudo sh -c "echo deb https://deb.nodesource.com/node_10.x cosmic main /etc/apt/sources.list.d/nodesource.list"

sudo apt-get update

sudo apt-get install nodejs
Guilherme Garcia
  • 115
  • 1
  • 10
2

You can:

sudo apt-get remove nodejs

Then:

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

Check if it was updated

nodejs -v

CedricYao
  • 167
  • 1
  • 12
0

It's unclear what you have already tried - "I have tried several methods" isn't enough information for me to help you. But I will give it a try ;-)

You should know which Ubuntu version your virtual mashine offers. Just type in your terminal: lsb_release -a

Now you are free to follow the instructions from:

rweisse
  • 820
  • 10
  • 26
  • Your right. I wasn't very specific. I am running Ubuntu 17.04. The top two links you provided were both some of the methods I tried. Looks like I may need to do a delete and reinstall. Thanks – Noahm888 Sep 20 '17 at 17:17
0

Have you tried cleaning your cache and re-installing using a clean version?

Using Command Line/Terminal:

    sudo npm cache clean -f
    sudo npm install -g n  
    sudo n 0.8.11  
    sudo n stable
    node -v

node -v will check for the current version of node.js installed on your system.

In addition you can try installing globally using:

    npm install npm@latest -g

Or manage your NPM versioning using at https://github.com/creationix/nvm:

    nvm use system
    nvm run system --version
    nvm install node

Hope this helps!

JRH
  • 39
  • 8
  • I tried all of these suggestions. Thank you. The `n` commands did not seem to do anything, neither did `npm install npm@latest -g`. `nvm install node` did update the version I have at `~/.nvm/versions/node/v8.5.0/bin/node` (the location `which node` returns), but `node -v` still returns v4.8.4 – Noahm888 Sep 26 '17 at 16:53
  • My pleasure. The final nvm sequencing worked for me when I was experiencing this problem. It was temporary and ultimately returned to the outdated version, however it did update it briefly. – JRH Sep 28 '17 at 16:16