Where is node.js installed on one-click droplet? Where do I put my server code?

November 24, 2016 2.1k views
Node.js Ubuntu 16.04

It's my first time using DigitalOcean and I just created a node.js 6.9.1 one-click droplet. I'm able to connect to it via SFTP.

I'm wondering:

  • where is node located on disk?
  • where should I put my server code?
  • how do I run node on this droplet?

Cheers!

Paul

2 Answers

Hi.

You should be able to call Node.js by executing nodejs (if that's not working it's node, but I think default is nodejs, can't check now).

To check version if you want:

  • nodejs --version

To check where is it installed, which will help you. It'll return where binary is located:

  • which nodejs

You can put code anywhere where you want. Then you start it with:

  • nodejs app.js

As this is working until you close session, you probably want to setup pm2 or forever. It'll help you to run node apps as a service.
DigitalOcean has great tutorial on this topic, covering everything you'll need - How To Set Up a Node.js Application for Production on Ubuntu 16.04.

by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.
  • Thanks for the response xMudrii. I'll go over the tutorial. Also, silly question, but how I log in to the droplet using ssh or the web console? I can't seem to login to either using our root password (sorry for the weird question, our sysadmin is no longer with us).

    • Try looking at How To Connect To Your Droplet with SSH.

      Also, try typing password manually, maybe copy is not working correctly. On Web Console, copy/paste doesn't work. For SSH, that depends on client.
      While you type, password is invisible, you don't see but it's there. :)

      by Melissa Anderson
      DigitalOcean Droplets are managed using a terminal and SSH. SSH is an encrypted network protocol for remote server login and command execution. It is the standard method used for accessing and interacting with Linux servers. This tutorial shows how to connect to a DigitalOcean Droplet for the first time by using the OpenSSH client.
Have another answer? Share your knowledge.