Home > Back-end >  How can i use env file in node
How can i use env file in node

Time:05-06

How can I use env file in node. When I create env file and put my mongo db user and password using DB_USER and DB_PASS it will not working now what can I do. DB_USER=deep DB_PASS=rkYcBBmeI1fAX03K

CodePudding user response:

You can use cross-env for pass env with command Or create .env file:

In this case, the parameters is available to you automatically

and can get env parameters as follows

process.env.DB_PASS

CodePudding user response:

For example, you can use confme. Its a great solution to stay compatible with standard dotenv but with additional validation and default layer. Also good solution for zero-configuration.

Validation schema must be implemented according to LIVR rules. Good decision to be sure of the integrity and correct values in your config.

  • Related