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

Written by Tommy
Posted on Tue, 01/26/2021 - 02:12
47 views

Share Everywhere

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.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Profile picture for user Tommy
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ể!”