1#Bash
2
3NODE_ENV=production && OTHER_ENV=foo && node ./index.js
4#or if you have your npm scripts set
5NODE_ENV=production && OTHER_ENV=foo && npm start
6
7#Powershell
8
9$env:NODE_ENV="production"; $env:OTHER_ENV="foo"; node .\index.js
10#or if you have your npm scripts set
11$env:NODE_ENV="production"; $env:OTHER_ENV="foo"; npm run build
12
13#CMD
14
15set NODE_ENV=production && set OTHER_ENV=foo && node .\index.js
16#or if you have your npm scripts set
17set NODE_ENV=production && set OTHER_ENV=foo && npm run build
1// get an environment variableexport const token = process.env['API_TOKEN'];// set an environment variable at runtimeprocess.env['RANDOM_ID'] = Math.random();