Alternatively you can do
node app.js NODE_ENV=production
and fetch that in your code
let env = process.env.NODE_ENV
make use of scripts in your package.json file to make this even easier
"scripts": { "dev": "node app.js NODE_ENV=development", "prod": "node app.js NODE_ENV=production" }
now you can run
npm run dev
or
npm run prod
depending on what variable you want
While NODE_ENV works just fine for this case, they arenโt an idiomatic solution for thr passing of information from cli command to program.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Alternatively you can do
and fetch that in your code
make use of scripts in your package.json file to make this even easier
now you can run
or
depending on what variable you want
While NODE_ENV works just fine for this case, they arenโt an idiomatic solution for thr passing of information from cli command to program.