The base installation of Amazon Linux 2 doesn’t have nodejs in it’s default repos. The way that is suggested by AWS is to use nvm to manage the installation. You can find the official documentation for that here:
To start, you need to SSH in, then use this command to install nvm, which is used to install NodeJS.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
It can then be activated by running this command
After that, you are able to install node with nvm using this command
nvm install node
Once that has completed, node should be installed on the server. You can verify that it is installed properly using this command.
node -e "console.log('Running Node.js ' + process.version)"
That should output the NodeJS version as it does here.
$ node -e "console.log('Running Node.js ' + process.version)" Running Node.js v15.10.0
Once that has completed, NodeJS is ready to use on the server and should be able to run your applications without any other issues.
Chris February 23rd, 2021
Posted In: Uncategorized