您好,欢迎来到宝玛科技网。
搜索
您的当前位置:首页[Node] Using dotenv to config env variables

[Node] Using dotenv to config env variables

来源:宝玛科技网

Install:

npm install dotenv --save

 

For example, we can store the sensitive information or env related information in a 'veriables.env' file:

// variables.env

NODE_ENV=development
DATABASE=mongodb://xxxxx
MAIL_USER=xx
MAIL_PASS=xx
MAIL_HOST=xxx.io
MAIL_PORT=2525
PORT=7777
MAP_KEY=xxxx
SECRET=xxx
KEY=xxx

 

Then we can use dotenv to load those configurations:

// import environmental variables from our variables.env file
require('dotenv').config({ path: 'variables.env' });

 

Now all the env related information will be stored in:

process.env

 

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- baomayou.com 版权所有 赣ICP备2024042794号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务