How to configure Systemd service unit to start Node app with "npm start" instead of "app.js"

Solution 1:

I'm running a similar setup on Debian, and my service looks like this:

...

[Service]
Environment=NODE_PORT=3000
Type=simple
User=www-data
Restart=on-failure
WorkingDirectory=/var/www/<your-code-directory>
ExecStart=npm start

...

Hope this helps!