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.
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.
@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
Click below to sign up and get $100 of credit to try our products over 60 days!
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 ;)