node js set node_env on start code example

Example: node start with environment variables

#Bash

NODE_ENV=production && OTHER_ENV=foo && node ./index.js
#or if you have your npm scripts set
NODE_ENV=production && OTHER_ENV=foo && npm start

#Powershell

$env:NODE_ENV="production"; $env:OTHER_ENV="foo"; node .\index.js
#or if you have your npm scripts set
$env:NODE_ENV="production"; $env:OTHER_ENV="foo"; npm run build

#CMD

set NODE_ENV=production && set OTHER_ENV=foo && node .\index.js
#or if you have your npm scripts set
set NODE_ENV=production && set OTHER_ENV=foo && npm run build