Howdy y’all,
I was following the Getting started after deploying NodeJS guide provided after setting up a Node.js Droplet and trying to get my personal website deployed. While I was trying to schedule my app.js to pm2, I encountered the following error:
root@DropletProjName:~/danaimone.com# sudo -u nodejs pm2 start app.js
[PM2][ERROR] Script not found: /root/danaimone.com/app.js
If I try to do a pm2 start app.js while logged in as root, without switching to the nodejs user, it adds fine. Unfortunately, this problem is interfering with deployment to the web since the nodejs user handles pm2 directly. I’m not sure if it’s because the folder is cloned on root and pm2 is not able to get the specific path. I tried an absolute path (/root/danaimone.com/app.js, /root/danaimone.com/app) to no success. I would appreciate any help y’all can provide on this!
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!
Hi! Make sure the nodejs user has permissions to read the file.
To view the file permissions: stat app.js or folder permissions together with other files ls -la /root/danaimone.com.
Grant access to all users to read and write app.js: chmod a+rw app.js
I had exactly the same problem.
I got it to work by cloning my repository into /var/www/html instead of at the root.
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.