zoukankan      html  css  js  c++  java
  • [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
  • 相关阅读:
    面向过程
    生成器
    迭代器
    装饰器
    函数及嵌套
    字符编码与文件操作
    linux_ssh
    LNMP
    BZOJ 3238: [Ahoi2013]差异
    BZOJ 3998: [TJOI2015]弦论
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6954384.html
Copyright © 2011-2022 走看看