How to setup a Node.js server on DigitalOcean

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

Published by


Andrew Golightly is the lead web developer here at Golightly+. He is a passionate fullstack JavaScript developer. He also runs an Empath Community.

Leave a Reply

Your email address will not be published. Required fields are marked *