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- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | 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

By | 2018-01-11T03:26:06+00:00 January 10th, 2018|blog|0 Comments

About the Author:

Andrew Golightly is the lead web developer here at Golightly+. He is a passionate fullstack JavaScript developer. And creates native apps too using React Native. To balance his love for coding, he also works as a counsellor.

Leave A Comment