Installing NPM on AWS EC2
To install NodeJS 6.x execute the following commands:
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -yum install nodejs --enablerepo=nodesource
Update
You can install NodeJS 7 and 8 in the same way. Just specify the version you need instead of 6 in the command above.
Update
To update to NodeJS 10 (or any other version) do the following:
rm -rf /etc/yum.repos.d/nodesource-el*curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash -yum install nodejs --enablerepo=nodesource
Follow this AWS Tutorial that uses Node Version Manager.
Node Version Manager (NVM) lets you install multiple versions of Node.js and switch between them.
Here are the steps:
Install NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
Activate NVM
. ~/.nvm/nvm.sh
Install Node (choose version)
nvm install 4.4.5
Confirm Successful Installation
node -e "console.log('Running Node.js ' + process.version)"