How do you use pm2 startup with a non-root user?
(Posted on behalf of the OP).
In fact that was the problem. Fixed via creating a symlink (as root):
ln -s /usr/bin/nodejs /usr/sbin/node
I don't know if it will help you but I use in this way:
- As a non-root user
pm2 startup -u <YOUR_NON_ROOT_USER>
- Copy line showed like
env PATH=$PATH:/usr/bin pm2 startup systemd -u delivery --hp /home/delivery
- As a root execute
env PATH=$PATH:/usr/bin pm2 startup systemd -u delivery --hp /home/delivery
- Back to non root user and type:
pm2 start <YOUR /PATH/TO/INDEX.JS> --name <YOU_APPLICATION_NAME>
- As a non-root type:
pm2 save
- reboot
sudo reboot
- As a non-root user type the commando bellow to check if it works
pm2 status
PS: Change as needed.
I hope it will be useful for you or someone.