jhonny lopez
jhonny lopez

Reputation: 325

which is the better way to set NODE_ENV according your npm run

I have tried figure out how set my NODE_ENV in nestjs according what i am doing, if run start in my local i expect NODE_ENV=development but if i run integration test then NODE_ENV=test. whats the best approach y pretend use cross-env and each npm run command use cross-env e.g "start:dev": "cross-env NODE_ENV=development node index.js" and so on, i want to know what do you think and your experience.

Upvotes: 0

Views: 402

Answers (1)

Erik Reder
Erik Reder

Reputation: 303

I honestly don't fully understand the question, but the way I set the environment variables (that is for node.js without nestjs on the IBM Cloud) is the following:

  • On local, I have a vcap-local.json file. If this file exists, I either declare this as local or read the values from there.
  • On the server, I either set the NODE_ENV variable directly in the app (there's some menu in the UI) or define the following commands in the deployment pipeline
cf set-env ${CF_APP} NODE_ENV test
cf restage

Does this answer your question somehow?

Upvotes: 0

Related Questions