How To Install NVM on Amazon Linux

Channel: Linux
Abstract: you can install any specific nodejs version on your system and use to run your application. This tutorial will help you to install NVM on your Amazon

NVM or Node Version Manager is a command-line utility for installing and managing multiple node.js versions on Linux based systems. With the help of NVM, you can install any specific nodejs version on your system and use to run your application.

This tutorial will help you to install NVM on your Amazon Linux machine. Also helped you to basic uses of NVM for Amazon Linux systems.

Prerequisites

A running Amazon Linux system with shell access. Login to your Amazon Linux system via SSH.

Step 1 – Installing NVM

Node Version Manager official team provides a shell script for the installation of NVM command line utility. Use the following commands to install NVM on Amazon Linux system:

sudo yum install curl -y 
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash   

This will create a .nvm directory under the logged in user home directory. NVM keeps all the binaries and configuration files under this .nvm directory.

Logout and login with your user account to load nvm environment or use the following command to load environment without login again.

source ~/.bashrc

At this stage, you have successfully install NVM on your system.

Step 2 – Installing Node using NVM

NVM allowed users to install multiple node.js versions for each user account. First of all, use the following command to find all available versions of node.js for installation:

nvm ls-remote 

Above command will show you a list of available node versions. Now you can install any node version by typing:

nvm install 12.19.0 

Just change 12.19.0 with your required version like 11.15.0, 10.11.0, etc.

It also provided alias for the latest stable node version, LTS version and other previous LTS version.

nvm install node          ## install latest stable version 
nvm install lts/*         ## install latest lts version 

You can also use lts/dubnium, lts/carbon etc.

Step 3 – Working with NVM

You can use the following command to list installed versions of node for the current user.

nvm ls 

With this command, you can find the available node.js version for the installation.

nvm ls-remote 

You can also select a different version for the current session. The selected version will be the currently active version for the current shell only.

nvm use 12.19.0 

To find the default Node version set for the current user, type:

nvm run default --version 

When you have multiple node.js version installed, You can choose specific version to run any script:

nvm exec 12.19.0 server.js 
Step 4 – Uninstall Specific Node Version with NVM

You can remove any unused version by running the following command. Just make sure the version you are removing is not currently active version.

To remove Node.js 10.12.0, type:

nvm uninstall 10.12.0 
Conclusion

This tutorial helped you to install and use NVM on Amazon Linux system. Also, you learned about basic uses nvm command line utility.

Ref From: tecadmin

Related articles