Hướng dẫn cài đặt nodejs on Amazon Linux 2 mới nhất

26th Jan 2021
Table of contents

In article I will tell you how to install nodejs on Amazon Linux 2.

First install NVM using CURL

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

Then run this command

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

To verify that nvm has been installed, do run this command

command -v nvm

After that, run this command to install Node 11 using NVM

nvm install 11

So you install NodeJS 11 on your EC2 instance. Now if you want to install a different version like NodeJs 12 then please run this command in your terminal

nvm install 12

This command installs nodejs on your EC2 instance, but it’s not the active version. To switch to NodeJs 12, please run the following command.

nvm use 12

Now you have activated Node 12 on your instance. To make Node 12 as the default version please run the following command

nvm alias default 12

This command will make 12 as the default Node version for this instance. Even if you stop and start your ec2 instance, Node 12 will be the default version on your machine. To check node version run the following command.

node -v

if you see the output like this “v12.20.0” then it means NodeJs installed on your EC2 instance successfully and your current node version is 12.20

Hope this will help you to get started with NodeJs. Feel free to watch my screen recording on youtube below.

Bạn thấy bài viết này như thế nào?
1 reaction

Add new comment

Image CAPTCHA
Enter the characters shown in the image.
Câu nói tâm đắc: “Điều tuyệt với nhất trong cuộc sống là làm được những việc mà người khác tin là không thể!”

Related Articles

Hiện nay, việc quản lý các web applications khá là phức tạp, ví dụ bạn phải quản lý load balancer, vài web servers, database servers

In this video we'll be setting up a new React App with AWS Amplify to add Sign up, Login and Logout in the easiest way possible.

In this hands on workshop Amazon Developer Advocate Nader Dabit shows us how to get started with serverless GraphQL using AWS Amplify.