How to Install Latest Node.js and NPM on Ubuntu with PPA

Step 1 – Add Node.js PPA

Node.js package is available in the LTS release and the current release. It’s your choice to select which version you want to install on the system as per your requirements. Let’s add the PPA to your system to install Nodejs on Ubuntu.

Use Current Release: At the last update of this tutorial, Node.js 14 is the current Node.js release available.

sudo apt-get install curl
curl -sL | sudo -E bash -

Use LTS Release : At the last update of this tutorial, Node.js 12.x is the LTS release available.

sudo apt-get install curl
curl -sL | sudo -E bash -

For this tutorial, I am using the latest current release and added their PPA to my system.

Step 2 – Install Node.js on Ubuntu

You can successfully add Node.js PPA to the Ubuntu system. Now execute the below command will install Node on Ubuntu using apt-get. This will also install NPM with node.js. This command also installs many other dependent packages on your system.

sudo apt-get install nodejs
curl -sL | sudo -E bash -

Step 3 – Check Node.js and NPM Version

After installing node.js verify and check the installed version. You can find more details about current version on node.js Official website.

node -v

Also, check the npm version

npm -v

Step 4 – Create Demo Web Server (Optional)

This is an optional step. If you want to test your node.js install. Let’s create a web server with “Hello World!” text. Create a file server.js

vim server.js

and add the following content to the file server.js

var http = require("http");
http.createServer((req, res) => {
res.writeHead(200, {"Content-Type": "text/plain"});
res.end("Hello World ");
}).listen(3000, "");
console.log("Server running at");

Now start the Node application using the command.

node server.js

debugger listening on port 5858
Server running at

You can also start the application with debugging enabled with the following commands.

node --inspect

Debugger listening on ws://
For help, see:
Server running at

The web server has been started on port 3000. Now access URL in your browser. Now you will need to configure a front-end server for your app.

Join The Conversation

Please to post.