Install a Node.js and Launch a Node App on Ubuntu 18.04

2 October 2020 by Feri Setyawan

In this article, we would like to discuss “how to install Node.js on Ubuntu 18.04”. This method can be performed on Dedicated Server/Bare metal and Virtual Private Servers or Virtual Machine like Cloud Raya.

However, in this article, we would guide you on how to install the Node.JS on Virtual Machine with Ubuntu 18.04 installed.

Node.js is a JavaScript platform for general-purpose programming that allows users to build network applications quickly. By leveraging JavaScript on both the front and backend, Node.js makes development more consistent and integrated.


Before we begin to the tutorial, the following are the stack versions that we are going to install:

  • OS: Ubuntu 18.04
  • Latest Node.js stable version for Ubuntu 18.04
  • Latest NPM

Install Node.js

apt update
apt install nodejs

By Default, from upstream it will install Node.js 8.10.0 version

Please type “y” to continue the installation process.

nodejs -v

Or, If you would like to install with another or specific Node.js version do you prefer you can use the following steps

Node.js v14.x:

# Using Ubuntu
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

Node.js v12.x:

# Using Ubuntu
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

Node.js v10.x:

# Using Ubuntu
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

Node.js LTS (v12.x):

# Using Ubuntu
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL | bash -
apt-get install -y nodejs

Node.js Current (v14.x):

# Using Ubuntu
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

Install NPM

Please run the following command to install NPM:

apt install npm

There will so much package and libs required to be installed and you can type “y” to continue the NPM installation. By default, from upstream it will install NPM 3.5.2 version.

Create Demo and Test Script

After we managed to install Node.js and NPM, we would test it out whether it’s installed properly or not. We can create a test file and append the following simple test script:

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

Please pay attention with the following syntax, please change with your Public IP that’s accessible from public and browser:


Please run the script that just created by using the following command:

node server.js

Open your browser and copy the following URL then paste it to your browser. You will see:


If you see the above message. Congratulation!! You have done the setup Node.JS to your Server.

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments

Ready to Make Something Big?

Deploy in Cloud Raya
Background wave