I have installed Node.js and Forever in my Raspberry Pi but I somehow don't know how to get Forever to start my hello.js
which is in the /node/
directory. I followed the tutorial, Run NodeJS server on boot with Forever on Raspberry Pi but cannot get it to work
- I cannot find
/var/www/
in my Raspberry Pi, as Forever seems to look for it to start any file. - if I
cd /node/
then runforever start hello.js
, it will work.
How can I do something like below?
@reboot /usr/bin/sudo -u pi -H /usr/local/bin/forever start /node/hello.js
1 Answer 1
I figured out how this work. It is because of root directory. In my raspberry pi 3b
, the root directory is /home/pi/
. So in my case, the whole script will be:
@reboot /usr/bin/sudo -u pi -H /usr/local/bin/forever start /home/pi/node/hello.js
then it works.