-->

    Social Items

How To Install Node.js On Ubuntu 18.04

How To Install Node.Js On Ubuntu 18.04 - In this post, we will learn how to install Node.js on Ubuntu 18.04. Node.js is a javascript runtime environment built on the Chrome V8 JavaScript engine to execute javascript code that is open source and can run on cross-platform (all platforms). The advantages of Node.js are Highly scalable, data-intensive, and real-time apps. To find out more, go to the website Node.js.

In this tutorial, the latest version of Node.js is 11.6.0 and for the LTS (Long Term Support) version is 10.15.0, I will use the latest version in this tutorial.

How To Install Node.js On Ubuntu 18.04


Via PPA (Package Personal Archive)

Open the terminal and follow the steps of each line

Step 1: Install Dependencies

$ sudo apt-get install curl python-software-properties


Step 2: Adding PPA

For Latest Version:
$ curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
For LTS Version:
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -


Step 3: Install Node.js

$ sudo apt-get install nodejs


Step 4: Testing

$ node -v
$ npm -v
Picture of Node.js Version
Picture of Node.js Version

Step 5: Hello World (Optional)

After the installation is complete, we can try to create a hello world with Node .js. Create a file with the name of helloworld.js.
$ nano helloworld.js

Insert the code below into the file.
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World from Codingster\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

To run the file we can do the following command line:
$ node helloworld.js

After the file helloworld.js running so we can view it by opening a browser and type 127.0.0.1:3000 in the address bar of the browser.

Picture Hello World with Node.js
Picture Hello World with Node.js

Conclusion:


Node.JS is a javascript runtime environment built on Chrome's V8 JavaScript engine to execute javascript code that is open source and can run on cross-platform (all platforms). There are several steps to install Node.js on Ubuntu, including adding PPA Node.js to Ubuntu, we can install Node.js with the latest version or the LTS version. The second step is to install Node.js with apt-get install. After the installation is complete we can see the version of Node.js installed on Ubuntu.

How To Install Node.js On Ubuntu 18.04

How To Install Node.js On Ubuntu 18.04

How To Install Node.Js On Ubuntu 18.04 - In this post, we will learn how to install Node.js on Ubuntu 18.04. Node.js is a javascript runtime environment built on the Chrome V8 JavaScript engine to execute javascript code that is open source and can run on cross-platform (all platforms). The advantages of Node.js are Highly scalable, data-intensive, and real-time apps. To find out more, go to the website Node.js.

In this tutorial, the latest version of Node.js is 11.6.0 and for the LTS (Long Term Support) version is 10.15.0, I will use the latest version in this tutorial.

How To Install Node.js On Ubuntu 18.04


Via PPA (Package Personal Archive)

Open the terminal and follow the steps of each line

Step 1: Install Dependencies

$ sudo apt-get install curl python-software-properties


Step 2: Adding PPA

For Latest Version:
$ curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
For LTS Version:
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -


Step 3: Install Node.js

$ sudo apt-get install nodejs


Step 4: Testing

$ node -v
$ npm -v
Picture of Node.js Version
Picture of Node.js Version

Step 5: Hello World (Optional)

After the installation is complete, we can try to create a hello world with Node .js. Create a file with the name of helloworld.js.
$ nano helloworld.js

Insert the code below into the file.
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World from Codingster\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

To run the file we can do the following command line:
$ node helloworld.js

After the file helloworld.js running so we can view it by opening a browser and type 127.0.0.1:3000 in the address bar of the browser.

Picture Hello World with Node.js
Picture Hello World with Node.js

Conclusion:


Node.JS is a javascript runtime environment built on Chrome's V8 JavaScript engine to execute javascript code that is open source and can run on cross-platform (all platforms). There are several steps to install Node.js on Ubuntu, including adding PPA Node.js to Ubuntu, we can install Node.js with the latest version or the LTS version. The second step is to install Node.js with apt-get install. After the installation is complete we can see the version of Node.js installed on Ubuntu.

Subscribe Our Newsletter