custom-env
custom-env copied to clipboard
Example on Loading from the current environment
Hello thanks for this but I am a bit confused on how to make the env automatically change if in production or development, i don't want to always be changing the value.
How to do so ? require("custom-env").env("development"); // change based on current environment as cant do an if check since its at the top of file.
Thanks.
Using a environment file name .env.development
-
Firstly set your require to below - Removing development and adding true (boolean).
require("custom-env").env(true); -
Set NODE_ENV to development. e.g. set NODE_ENV=development in your package.json
Using a environment file name .env.development
- Firstly set your require to below - Removing development and adding true (boolean).
require("custom-env").env(true);- Set NODE_ENV to development. e.g. set NODE_ENV=development in your package.json
Hello, thanks, I did tried that, i am on windows and using this in node.js, i use nodemon so i always starts by using npm run server .
package.json

env files

index.js

Error

Update: ended up using cross-env with dotenv-flow i think my mistake was i was i was adding && after NODE_ENV=production