Skip to main content

How to setup a Node.js server on DigitalOcean

· One min read

Once your droplet is created and you’ve ssh’d in, it’s time to set some things up..

I start off by installing nvm. You can find the command for the install script here. At the time of writing, I used

curl -o- | bash

I needed to exit my terminal, and then ssh back in.

Then, for me, I want the latest LTS from Node.js installed.

So I run nvm install --lts

Also I want the lts versions to be my default node with nvm.

So type nvm alias default lts/*

As a personal preference I then clone out my repo to /var/server

Once in there, of course run npm install

Then I like to setup forever, so I can make sure the server runs indefinitely.

npm install -g forever

Then it’s just a matter of starting up your server. So something like

forever start my-server.js