How to Install of Node.js 12 on Ubuntu / Debian / Linux Mint
You can use the apt package manager to install the Node.js 12 using Terminal on your Linux Mint system and first there are some dependencies that you need to install and for that execute:
After installing the necessary dependencies execute the below mentioned command to install Node.js:
Run the command given below to confirm the installation of Node.js by checking version:
Now if you want to remove the Node.js in case you installed it through apt then execute:
Getting Started with Node.js 12 on Ubuntu / Debian / Linux Mint
Follow the steps mentioned below to use the Node.js 12:
Step 1: Execute the command given below to create a file including text you want to display on the server:
Step 2: Now add the below given code on the file you created:
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 and welcome to Linuxhint!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Once you have added the above given code, now save this file, and close it.
Step 3: Execute the below command to make the node.js server run and then click on the server address:
When you click on the server address you will be directed to the file you created on the server:
Conclusion
Node.js is a famous programming environment used to do frontend as well as backend programming. Node.js is extraordinary as it can create advanced applications. You can install Node.js on
Linux Mint by using Apt repository and installation command and using software manager. The guide mentioned in the article also makes you learn the use of Node.js.