1

I need my project to have different configurations as per environments, production, development & local.

I searched so two different suggestions are made by people:

1] Making use of env.json, See this thread

2] .env file ( Here I am not sure how to name file for prod & dev ), See this npm plugin

I am confused about what is officially supported for express js server.

Prashant
  • 4,474
  • 8
  • 34
  • 82
  • 1
    Official way is explained on official website : http://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production – BENARD Patrick Jul 09 '19 at 11:07
  • So process.env is official but how about loading different environments? I ended up using tool https://www.npmjs.com/package/dotenv – Prashant Jul 09 '19 at 14:19
  • 1
    @pcj, you are using the right too ([dotenv](https://www.npmjs.com/package/dotenv)), check the doc for how to setup environment variables on various deployments and how to ignore `.env` file to githhub or other services like github. – The Alpha Jul 09 '19 at 16:14
  • 1
    @TheAlpha, Thanks, I have made changes as per the documentation provided by dotenv tool. – Prashant Jul 10 '19 at 05:17

0 Answers0