pm2 calls node, not nodejs

November 15, 2015 1.2k views
DigitalOcean Node.js Ubuntu

I installed pm2 following instructions. When I attempt to execute:

pm2 start app.js

It seems like it is looking for "node", but when I installed node js, the command to run node is "nodejs" (something with name clash in ubuntu).

How can I setup pm2 to run "nodejs" instead of "node"?


1 comment
  • Thanks for your quick response.

    I thought I had nodejs Ubuntu package, but it what I installed told me that I needed to use "nodejs" instead of "node" to run,, that tells me that I got a different distribution.

    I am thinking of rebuilding the droplet and start fresh (my source and data are backed up in another server), would you point me to the proper Ubuntu distribution? (a command to install would be nice ;)

3 Answers

I would alias node to nodejs which is the conventional name for the nodejs binary. If you are sure that you are not going to install the nodejs Ubuntu package any time in the future, you can just create a symlink /usr/bin/node that points to /usr/bin/nodejs. This way, pm2 and any other packages that use the nodejs binary can refer to it as just node:

sudo ln -s "$(which nodejs)" /usr/bin/node

Regarding Ubuntu nodejs installation and the renaming of "node" to "nodes" ... I am still confused.

I found the following instructions to install nodejs on Ubuntu:

Please note comment on the page:

"Because of a conflict with another package, the executable from the Ubuntu repositories is called nodejs instead of node. Keep this in mind as you are running software."

Yet, your pm2 instructions seems to want "node" to be the command to run nodejs applications.

What I am doing wrong?

Please advise.

by Justin Ellingwood
Node.js is a popular Javascript platform that can be used to build web applications quickly and easily. Node.js uses Javascript on both the front-end and back-end to create a more consistent experience for developers. In this guide, we'll get you up and running with Node.js on an Ubuntu 14.04 server.

@contrerasjorgev - The default method of installing NodeJS from the CLI is by using apt-get. If you are in need of the latest release, something repositories often do not provide, you'll need to compile from source (which is honestly a better option).

You can download a simple bash script that functions as an auto-installer to simplify the installation. I would look at

Simply download the file, run a chmod +x on it from the CLI and execute and it should handle the basics for you without any issues.

You'll still want to run apt-get install npm or install it from source as well (depending on what you prefer to do). Make note, however, that the above bash/shell script will install NodeJS to /usr/local/, so you would still need to create a symlink, or modify the bash script to extract to /usr/bin instead.

Have another answer? Share your knowledge.