I have a package.json with following (simplified) content in the scripts key:
...
scripts: {
\"start\": \"NODE_ENV=${NODE_ENV:=production} node start-app.js\"
You have a few options:
env
for each command separatelypoststart
script, you can concatenate commands for npm like so: "start": "NODE_ENV=${NODE_ENV:=production} node start-app.js && echo $NODE_ENV"
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)