gpt4 book ai didi

node.js - nconf 不会从配置文件中删除这些值

转载 作者:太空宇宙 更新时间:2023-11-04 01:05:32 25 4
gpt4 key购买 nike

我有一个如下所示的配置文件。我正在尝试删除 customLog2 值:

{
"customLog2": {
"key": "2",
"value": "example"
},
"customLog3": {
"key": "3",
"value": "result"
}
}

nconf.file(configFile);
nconf.remove('customLog2');
nconf.save(function (err) {
fs.readFile(configFile, function (err, data) {
if (err) console.log(err);
console.dir(JSON.parse(data.toString()))
});
});

我仍然在文件中看到 customLog2。

最佳答案

根据nconf README documentation ,remove 函数用于从 nconf 对象中删除整个“数据存储”,而不是单个键。

它与 add/use 相反方法。

关于node.js - nconf 不会从配置文件中删除这些值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23453901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com