Hướng dẫn cài đặt nodejs on Amazon Linux 2 mới nhất
26th Jan 2021In 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