Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install a specific nodejs version with apt-get

I am a newbie with Linux general, and here's what I am trying to achieve:

I am trying to install nodejs version on Debian Linux with the following command:

apt-get install nodejs=8.14.0

But I get this error in return:

E: Version '8.14.0' for 'nodejs' was not found

As far as I found, this is the correct way to specify a version. If I do this, then it works fine:

apt-get install nodejs

But I need this specific version, and not the latest one. I am doing this for a Docker image, so it has to be installed at runtime.

like image 270
nullpointer Avatar asked Feb 05 '20 19:02

nullpointer


People also ask

How do I install a specific version of Node apt get?

To install a particular version of node, use the command nvm install and add the number of the version.

How do I install a specific version of Node in a project?

npm install <package-name> –save: this command will install an NPM package within the dependencies in your package. json file. npm uninstall <package-name>: this command will uninstall a specific package. npm update <package-name>: it will update a specific package to the available latest version.

How do I run a specific version of node js?

The n command for installing and activating a version of Node is simple: n 6.17. 1 . You could also use n latest for the latest version of Node or n lts for the latest LTS version of Node. If the version of Node is already installed, then n will simply switch to that version.


1 Answers

Make sure you have the following packages:-

sudo apt-get install \
    apt-transport-https \
    curl \
    software-properties-common

Enable the NodeSource repository by using a command:-

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

After enabling the repository, install Node.js using a command:-

sudo apt-get install nodejs
like image 110
Munish Avatar answered Sep 21 '22 20:09

Munish