You have a few options:
- better-npm-run,which can define an
envfor each command separately - Instead of a
poststartscript, you can concatenate commands for npm like so:"start": "NODE_ENV=${NODE_ENV:=production} node start-app.js && echo $NODE_ENV" - Use a process manager in production like pm2. pm2 lets you define environment specific json files with settings such as
NODE_ENV. At our company, we successfully run all of our apps in different environments with pm2 (all the while having the same start command)