I liked Daniel's solution, but I thought it would be even cleaner to put it in a separate file, startup.sh :
#!/bin/sh if [ "$NODE_ENV" = "production" ]; then node src/index.js; else nodemon src/index.js; fi
Then just change package.json to:
"scripts": { "start": "../startup.sh" },
source share