method 1: set NODE_ENV for all node apps
Windows:
set NODE_ENV=production
Linux or other Unix based system:
export NODE_ENV=production
method 2:set NODE_ENV for current app
NODE_ENV=production node app.js
method 3: create .env file and use env-cmd package
env-cmd .env node app.js
method 4: use cross-env pacakge
in package.json
"build:deploy":"cross-env NODE_ENV=production webpack"