How to upgrade Node.js from version 8 to 10 on Linux Ubuntu, via SSH?

Asked

Viewed 7,933 times

2

I tried several tutorials on the internet before coming to post the doubt here on Stackoverflow and no tips worked. My repository is with version 8 of Node and the same, even removing, back.

I need to install Node 10.

I’ve tried to:

sudo apt-get purge nodejs

sudo apt-get purge --auto-remove nodejs

udo apt-get purge nodejs
sudo apt-get autoremove

And remove. And when I use the Digitalocean tutorial that says:

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

And then:

sudo apt install nodejs

Reinstall version 8 and not 10 on Node.

What am I doing wrong?

  • Good afternoon, unfortunately I use centos in digitalOcean, but I had no problems to remove and install nodejs, check on Repositório Oficial nodesource If something does not help, it has step by step step for manual installation of nodejs in any version in any linux distro with nodesource support.

  • Reading the official repository, in the Manual installation section, says that it is necessary to remove the old PPA and then add the new one, with the new version of Node.

4 answers

5

Use the npm module to update the Node

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

To upgrade to the latest version (and not current stable), you can use

sudo n latest
  • Oi @Iago Carvalho, por é, says npm does not exist: sudo: npm: command not found and Node is installed there: root@ubuntu-s-1vcpu-2gb-fra1-01-pppoker:~# Node -v V8.10.0

  • and good in case you would have to purge the Node and install again using the Curl -Sl https://deb.nodesource.com/setup_10.x | sudo -E bash - command and then give sudo apt-get install -y nodejs as it says in the Node documentation

  • 1

    can take a look at: https://github.com/nodesource/distributions/blob/master/README.md#debinstall

  • Very obligatedaaaaaa Iago Carvalho.

2


Go to /etc/apt/sources.list. d , and check the Node.sourcelist file for any reference to the node_8.x.

If you do, delete, make Curl to version 10 again by default, apt update, and then apt install nodejs.

-2

One step was missing.

    > curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
    > sudo bash nodesource_setup.sh
    > sudo apt install nodejs
    > node -v
  • 1

    Hello Davisson, the part from curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh and of sudo bash he did, being in the body of the "question", the problem is that apt was not recognizing the 10 even so, it continued forcing the 8, so this supposed missing step does not solve what WAS ASKED, it was a problem in source.list, read the other https answer://en.stackoverflow.com/a/353349/3635, the source.list problem may even be a "bug" or failure caused by another installation. Thank you for understanding.

-2

I had the same problem because I had an error repository, in my case Spotify, however the command "Curl -Sl https://deb.nodesource.com/setup_10.x | sudo bash - "not worked because it could not update. I removed the Spotify package and it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.