How to set process.env from the file in NodeJS?

前端 未结 2 1337
刺人心
刺人心 2020-12-19 02:27

I\'m new to the Node.JS. I found few articles says we can use .env file to setup the process.env variable, e.g.,

PORT = 8081

but when I run

2条回答
  •  清酒与你
    2020-12-19 03:00

    Dotenv file have become the most popular mode to separate configuratione from app, using system environment variables (see 12factor config).

    On node there exists a lot of libraries for loading config from .env file. The most popular is motdotla/dotenv. You can read a lot of examples on readme file about the usage of this library

提交回复
热议问题