If you are looking to install Node.js on Ubuntu Linux, you’re in luck. Node.js is available in the Ubuntu repository and you can easily install it with a few commands.
If you’re planning to install Node.js, you probably already know what it is. I’ll go over it quickly anyway.
Node.js “is an open-source, cross-platform runtime environment for developing server-side Web applications”. Its simplicity for building and deploying fast and scalable applications has made it one of the most popular web technologies of recent years.
Node.js is supported by npm (Node.js Package Manager). It’s an open-source library of Node.js packages. So you can use one in your application without needing to rewrite the entire thing all on your own.
Enough talking about Node.js and
There are two main ways you can install Node.js and npm on Ubuntu:
- Using Ubuntu’s official repository: Easy to install using apt but might have an older version.
- Using NodeSource repository: Slightly more complicated but you can choose which version to install, including the latest release of Node.js.

Install Node.js and npm on Ubuntu using the official repository
As I said earlier, Node.js is available on Ubuntu. So all you need to do is to open a terminal and use the following command:
sudo apt install nodejs
To install npm, use the following command:
sudo apt install npm
I recommend installing npm as well because you’re going to need it anyway. Both Node.js and npm are quite small.
For working on Node.js, you can use any good code editor for Linux or an IDE. It’s basically your preference.
I’m not going to show you how to get started with Node.js because that’s not the purpose of this quick tutorial.
If you want to remove Node.js and npm, you can use the command below:
sudo apt remove nodejs npm
Note: If you’re getting a “/
What happens here is that the program looks for the
ln -s /usr/bin/nodejs /usr/bin/node
Install Node.js and npm on Ubuntu using NodeSource repository
You can install Node.js and
What you have to keep in mind is that you need to specify which major version of Node.js you want to install.
Let’s say you want to install Node.js version 11. First, install Curl on Ubuntu:
sudo apt install curl
Now you can use the following command:
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
If you want to install Node.js version 10, you can replace setup_11.x with setup_10.x.
The above command will download and start running the installation script. The script will add a new repository in the source list directory (/etc/apt/sources.list.d). It will also add the GPG key of the new repository automatically.
With this new repository added to the sources list, you can install
To install the Node.js package, use the following command. Npm is also installed with this package.
sudo apt install nodejs
Once installed, you verify it by checking the installed version of Node.js with this command:
node --version
The output should be like this:
node --version
v11.6.0
You can also verify the npm installation:
npm --version
The output should be similar to this:
npm --version
6.5.0-next.0
That’s all you need to do to install Node.js on Ubuntu 18.04 and 16.04. I hope you found this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.
After that, if you really love Node.js, you should check out NodeOS, a Linux distribution for Node.js users.

Instead of installing one node-version, I recommend to use the excellent tool nvm. With nvm you can easily install, switch between and manage as many node-versions you want. If you are into nodejs, you should visit https://github.com/nvm-sh/nvm
I second NVM. Best way to manage nodejs+npm.
thanks, always love seeing your site pop up in the search results
had installed the nodesource snap and it was not playing fair
Is it possible to install node js version 10 on ubuntu 14.04
Please can you tell me where I can find the path of the npm binary after running `sudo apt install npm`. This is not added to my PATH automatically. Thanks
This an old question…but for those who are still discovering it in 2020, here are my thoughts.
Generally better to install nodejs/npm from the source because the distro generally lags and isn’t easy to have multiple versions installed.
Not sure where the distro stores npm, but I’d highly recommend using nvm (node version manager) to install both nodejs and npm. You can find it here: https://github.com/nvm-sh/nvm
# I install nvm with the following:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
# re-read to get nvm environment setup
$ source ~/.bashrc
# will list all the nodejs versions available
$ nvm ls-remote
# now install one
$ nvm install v12.18.4
Done! It is that easy. If you want to have multiple versions installed, you can do that too.
$ nvm install v8.17.0
# list the nodejs/npm version that will be used
$ nvm current
# list all local versions of nodejs/npm
$ nvm ls
# switch to v12.18.0 and its npm
nvm use v12.18.0
# switch back to v8.17.0 and its npm
nvm use v8.17.0
-RB