How to Install NodeJs on Amazon Linux Easily

0

Node.js is an open-source server-side runtime environment built on Chrome’s V8 JavaScript engine. It helps to build a highly scalable server-side application using JavaScript. In this article, I am going to share how to install NodeJs on Amazon Linux.

Installation Steps

Step 1: Configure Yum Repository

To install NodeJs on Amazon Linux, first ssh into the amazon linux instance and configure the yum repository. Run the following commands to enable node.js yum repository.

For Latest Release

$ sudo yum install -y gcc-c++ make 
$ curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash - 

For Stable Release

$ sudo yum install -y gcc-c++ make 
$ curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash - 

Step 2: Install NodeJs on Amazon Linux

Once the node.js packages enabled, install NodeJs by running following command with NPM.

$ sudo yum install -y nodejs 

Step 3: Check NodeJs Version

After installation of Node.js, check the version of node.js by following command.

$ node --version

Check NPM(Node Package Manager) of version

$ npm --version

Test NodeJS Server

Check your node.js server by creating a server with sample text “Welcome to Node.js Server“. Let’s create a file check_server.js

$ vi check_server.js

Add following code snippet to the file.

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Welcome to Node.js Server');
}).listen(3000, "0.0.0.0");
console.log('Server running at http://13.233.158.211:3000/');

Output on the terminal on successful execution

how to install NodeJs on Amazon Linux

Check the server on the browser.

http://13.233.158.211:3000/

Output on the browser.

how to install NodeJs on Amazon Linux

Read More: How to Install Nodejs on EC2 Ubuntu Server [Step by Step Guide]

Conclusion

In this tutorial, you have learned how to install NodeJs on Amazon Linux. If you have any doubts feel free to contact me, I will definitely try to help you. Also, you can join our elite Facebook group to get direct help from me. If you like this tutorial, please share this article on your social media handle.

LEAVE A REPLY

Please enter your comment!
Please enter your name here