Here is an easy way to install Node.js on an AWS EC2 instance running Amazon Linux.
Run as root on RHEL, CentOS or Fedora, for Node.js v6 LTS:
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
Alternatively for Node.js 8:
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
Alternatively for Node.js 0.10:
curl --silent --location https://rpm.nodesource.com/setup | bash -
Then install, as root:
yum -y install nodejs
Test: Run node -v. The version should be higher than v0.10.32.
Node comes with npm installed so you should have a version of npm. However, npm gets updated more frequently than Node does, so you’ll want to make sure it’s the latest version.
npm install npm@latest -g
Test: Run npm -v. The version should be higher than 2.1.8.