Technology · July 27, 2022

Install Node.js on Amazon EC2 with Ubuntu 14.04

A step-by-step tutorial for installing Node.js v4 on an Amazon EC2 Ubuntu 14.04 instance using the package manager.

Amazon EC2 provides a free tier program for you to experiment and create your own projects. Recently I wanted to install Node.js in Amazon EC2 with Ubuntu 14.04 as the operating system. I was surprised to find that there was no article with clear instructions on how to install Node.js version 4, so I wrote this tutorial.

Steps:

  1. Login to your AWS Console
  2. Select EC2 under Services
  3. Click on Launch Instance
  4. Select Ubuntu 14.04
  5. Click on Edit Security Groups and add HTTP on port 80 and HTTPS on port 443
  6. Download your key pair
  7. Once it is running, right-click and select Connect

Connecting via SSH:

chmod 400 your-key.pem
ssh -i "your-key.pem" ubuntu@your-public-dns.compute.amazonaws.com

Installing Node.js via nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 4
nvm use 4
node --version

This will install Node.js v4 on your EC2 instance. You can then install your application dependencies and start your server.