Installing Specific Version of Nodejs

Installing Specific Version of Nodejs

Thank you for joining, I need some help, this could be easy but I'm new to linux. I want to install NodeJS latest version by following the guide posted here, as the version my official sourcelist gives me is very old.

These are the suggested commands:

curl -fsSL  | sudo -E bash -
sudo apt-get install -y nodejs

But the problem is the old version gets installed instead..

sudo apt list nodejs

Listing... Done
nodejs/unknown 18.0.0-deb-1nodesource1 amd64
nodejs/oldstable,oldstable 10.24.0~dfsg-1~deb10u1 i386

apt-cache policy nodejs
nodejs:
  Installed: (none)
  Candidate: 10.24.0~dfsg-1~deb10u1
  Version table:
     10.24.0~dfsg-1~deb10u1 500
        500 debian buster/main i386 Packages
        500  buster/updates/main i386 Packages

This is my OS: OS: Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster

I tried using sudo apt-get nodejs=<version> but it failed for the new 18 version yet worked for the old one.

1 Answer

I tried to run your commands and it fails because it runs all the needed commands once time. So, it doesn't install the repos, and then when you try to search it found the old version of nodejs.

Try to run the following commands separately:

$ curl -s  | sudo bash
$ sudo apt install -y nodejs

Otherwise, I suggest using NVM () which allows you to install different versions of nodejs

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.