I\'m working on a Raspberry Pi running Raspbian running a Node.js app and trying to get it to start when the Pi boots. I found a couple of examples but I can\'t seem to get it
Mohit is right, but just for clarification, you can use readlink to find the full path for your Node.js app as it will be needed later to add as a cron job.
readlink -f <>
For instance readlink -f HAP-NodeJS/Core.js
results in /home/pi/HAP-NodeJS/Core.js
You can also use which node
to find the full path where node.js is installed
Next, create a new cron job using sudo crontab -e
and add the following code at the very end:
@reboot sudo /usr/local/bin/node <<.js application path>> &
for instance, my code looks like this.
@reboot sudo /usr/local/bin/node /home/pi/HAP-NodeJS/Core.js &
Upon reboot (or start up) , your Node.js should run. Hope this clears things.