Question

pm2 calls node, not nodejs

I installed pm2 following https://www.digitalocean.com/community/tutorials/how-to-use-pm2-to-setup-a-node-js-production-environment-on-an-ubuntu-vps 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”?

Thanks.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@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

https://github.com/taaem/nodejs-linux-installer/releases

Simply download the node-install.sh 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.

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:

https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server

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.

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