美文网首页
node config

node config

作者: 寻找无名的特质 | 来源:发表于2024-01-22 06:19 被阅读0次

node 读取配置文件有多种方式,使用config是比较简单的方式。

首先需要安装config:

npm install config

然后可以使用:

const config = require('config');
console.log(config)

在项目路径下创建config目录,在目录中创建default.json保存配置项,也可以创建开发时和生产时的配置文件product.json和development.json,node会根据项目状态读取相应的文件。

相关文章

网友评论

      本文标题:node config

      本文链接:https://www.haomeiwen.com/subject/ahedodtx.html