How to start a Node.js app on system boot?

前端 未结 3 2101
北海茫月
北海茫月 2021-02-04 12:53

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

3条回答
  •  死守一世寂寞
    2021-02-04 13:40

    I solved this problem by first checking where node.js was installed on RaspberryPi:

    which node
    

    This gave me :

    /usr/local/bin/node
    

    Open crontab config:

    sudo crontab -e
    

    Then in my crontab :

    @reboot sudo /usr/local/bin/node  &
    

    Save, reboot, and problem solved !

提交回复
热议问题