Install Node.js and Setup Express

by Amit Biswas Posted Feb. 23, 2017

Before you start, make sure you know how to SSH to the server. Learn about that here.

If you are home (read: not connected to NYU wifi) you have to use NYU VPN). Scroll down the page to see the download link for the vpn client for your platform (Windows, Mac etc.). When the vpn client asks for the server address use vpn.nyu.edu and use your typical netid and password to authenticate.

Install Node.js

Node.js is JavaScript based runtime for building server-side and networking applications. We will go over how to compile and install Node.js on your local account on Code. Essentially, you will be able to use npm and install packages as needed without requiring sudo access.

First modify your local PATH environment variable.

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc

We are prepending a directory into the system path, so it will check this local directory inside your home folder first, before looking at system folders to find and run applications. For example, if both the server and you on your local account on the server had Node.js already installed, this modification of the PATH variable would force the use of your Node.js binary instead of the Node.js installed in the system.

source ~/.bashrc

source just runs the content of the file passed in as arguement. This command is analogous to . ~/.bashrc.

Make two directories: one for the compiled binary of Node.js and npm, and the other for storing the installer files for Node.js.

mkdir ~/local ~/node-latest-install

Change directory to ~/node-latest-install

cd ~/node-latest-install

Download and extract the latest tar file of Node.js installer and extract the contents in the current directory.

curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1

Set the directory where Node.js binary will be installed at.

./configure --prefix=~/local

Install Node.js. This will take a while. Go get a latté. You deserve it. Run the command before you get the latté. Don't close your laptop though. If the ssh connection is lost, make install process will be killed, and you will have go on another latté trip.

make install

Install npm

curl -L https://www.npmjs.org/install.sh | sh

Setup Express and "Hello World" App

Follow the official documentations below and you should be on your way to building the next best thing!