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.
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!
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:
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.
@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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.