
How to Install and Configure Node.js on EC2 Instance Amazon Linux 2
- Mohammad Abu Mattar
- Cloud Computing
- 07 Nov, 2022
- 02 Mins read
Introduction
Node.js does not exist in the default Amazon Linux 2 repository. So, we need to add the Node.js repository to the system. In this post, we will learn how to install and configure Node.js on EC2 Instance Amazon Linux 2.
Prerequisites
- AWS Account
- EC2 Instance Amazon Linux 2
- SSH Client
Step 1: Update the System Packages and Install Dependencies Packages
First, we need to update the system packages and install dependencies packages.
# Update the system packagessudo yum update -y
# Install dependencies packagessudo yum install gcc-c++ make -y
Step 2: Install Node.js
First, we need to install Node.js on our EC2 Instance. To do that, we need to add the Node.js repository to the system. To add the Node.js repository, we need to run the following command:
# Install Node.js repository 14.xcurl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
# Install Node.js repository 16.xcurl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
# Install Node.js repository 17.xcurl -sL https://rpm.nodesource.com/setup_17.x | sudo bash -
# Install Node.js repository 18.xcurl -sL https://rpm.nodesource.com/setup_18.x | sudo bash -
Step 3: Install Node.js
After choosing the Node.js version, we need to install Node.js on our EC2 Instance. To do that, we need to run the following command:
# update the systemsudo yum update -y
# Install Node.jssudo yum install nodejs -y
Step 4: Check Node.js Version
After installing Node.js, we need to check the Node.js version. To do that, we need to run the following command:
node -v
Output depends on the Node.js version that you choose.
# Node.js 14.xv14.18.1
# Node.js 16.xv16.13.0
# Node.js 17.xv17.0.1
# Node.js 18.xv18.0.0
Conclusion
In this post, we learned how to install and configure Node.js on EC2 Instance Amazon Linux 2. We learned how to add the Node.js repository to the system and install Node.js on our EC2 Instance.