A systemd unit file keeps your app running, restarts it if it crashes and starts it on boot.
# /etc/systemd/system/myapp.service [Unit] Description=My app After=network-online.target [Service] User=pi WorkingDirectory=/home/pi/myapp ExecStart=/usr/bin/node server.js Restart=on-failure [Install] WantedBy=multi-user.target # then: sudo systemctl daemon-reload sudo systemctl enable --now myapp