Install it by running: bash copy the code npm install if-env --save make sure you don't install it as a "development dependency" as we will need it in production as 11-digit phone number format philippines well. Now you just need to modify your npm scripts in your package.json: json copy the code "scripts": { "start": ?? Npm run start:prod || npm run start:dev", "start:dev": "nodenv -f .

start:prod": "node ." } this script will then execute npm run start:prod, then node . If node_env has the value production, and otherwise will execute npm run start:dev, then nodenv -f .. You can also use this technique with any other environment variable. For example, try running: bash copy the code # should output "the value of foo is: bar" npm start # should output "the value of foo is: undefined" node_env=production npm start if you want to know more about if-env , check out its documentation .