Node.js is an open-source, cross-platform JavaScript runtime environment. Using Nodejs, you can build fast, highly scalable applications. In this tutorial, you will learn to configure the yum repository, how to install Nodejs on Amazon Linux EC2 instance, check the NodeJs version.
You can download and install latest releases from here.
Nodejs Installation on Amazon Linux
Log in to the AWS console and create an instance with Amazon Linux.
Step 1: SSH into the EC2 Instance
First, SSH into the Amazon Linux EC2 instance. By default user name is ec2-user.
$ ssh -i Serverkey.pem ec2-user@IP Address of the Instance
Step 2: Install Node Version Manager
Second, install node version manager (nvm) by typing the following at the command line.
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
Step 3: Activate NVM(Node Version Manager)
Next activate NVM by running following command.
$ . ~/.nvm/nvm.sh
SSH into the AWS instance and update repository. Now enable node.js yum repository in your system by the following command.
Step 4: Install Node.js using NVM
Finally install Nodejs using NVM, which also install NPM(Node Package Manager).
You can install any package using NPM.
$ nvm install node
Step 5: Check Node.js Installation
Check your Node.js installation by running the following command.
$ node -e "console.log('Running Node.js ' + process.version)"
Conclusion
By now you have learned how to install Nodejs on Amazon Linux. If you have any doubt feel free to comment below. I will answer all the queries.