更新我已经阅读了StackOverFlow上的Node Environment Setting(节点环境设置)文章,但是它们是使用3rd party包引用的,它们都没有告诉您详细的步骤. (是Windows系统环境,还是Linux环境变量...但是如何将设置放入我的项目文件夹中?!)解决方案 Dotenv文件已成为使用系统环境变量将配置与应用程序分开的最受欢迎的模式(请参阅 12要素配置).在节点上,存在许多用于从.env文件加载配置的库.最受欢迎的是 motdotla/dotenv .您可以在自述文件上阅读有关该库用法的许多示例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 = 8081but when I run the program in my node, it is still 8080 PORT (by default). The question is how can I setup the env variable in Node without any other 3rd party module's help? (I found there are few 3rd party package to management the env config, but... it is kind confused, different package might have different rule and more complex use cases; I want to start from clear way to study purely nodejs)UpdateI have read Node Environment Setting post on StackOverFlow, but they are refer using 3rd party package, none of them tells the detail steps. (Either windows system environment, or Linux environment variables... but how can I place the setting into my project folder?!) 解决方案 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 这篇关于如何从NodeJS中的文件设置process.env?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-06 13:00
查看更多