Skip to content

Install Node.js#

Official page: https://nodejs.org

You may also be interested in NPM (Node.js Package Manager).

Install Node.js via Node Version Manager (linux, macOS, WSL)#

In practice, it may be useful to be able to quickly install and use different versions of Node.js via the command line.

See https://github.com/nvm-sh/nvm#installing-and-updating

Install Node.js (all platforms)#

Main downloads page (now already includes npm): https://nodejs.org/en/download

Many updated versions for package managers can be found at: https://nodejs.org/en/download/package-manager/

Install Node.js (Ubuntu 20.04 Focal)#

sudo apt install nodejs # install node 10.19.0

Install Node.js (Ubuntu 18.04 Bionic)#

sudo apt install nodejs # install node 8.10.0

Install Node.js (Ubuntu 16.04 Xenial)#

sudo apt install nodejs-legacy # install node 4.2.6

Install specific Node.js version (Ubuntu)#

First remove node:

sudo apt-get remove nodejs npm  

Then update & upgrade:

sudo apt-get update
sudo apt-get upgrade

Then get your desired Node version (where setup_12.x, replace with desired major version):

curl -sL deb.nodesource.com/setup_12.x | sudo -E bash - 

And then install your new node version:

sudo apt-get install -y nodejs

Check installed Node.js version#

node -v