Node.js 为什么会出现错误:配置属性“;jwtPrivateKey&x201D;没有定义吗?

Node.js 为什么会出现错误:配置属性“;jwtPrivateKey&x201D;没有定义吗?,node.js,config,Node.js,Config,当我通过NodeJS终端运行index.js文件时,我一直收到这个错误消息。我的编辑器是VS代码。我在窗户上 我将npm配置模块加载到index.js文件中。我创建了一个custom-environment-variables.json。我在节点终端中设置密码vidlyPrivateKey。我不知道为什么会这样。任何帮助都将不胜感激 以下是我的index.js代码: const config = require('config'); try { const myKey = config.

当我通过NodeJS终端运行index.js文件时,我一直收到这个错误消息。我的编辑器是VS代码。我在窗户上

我将npm配置模块加载到index.js文件中。我创建了一个custom-environment-variables.json。我在节点终端中设置密码vidlyPrivateKey。我不知道为什么会这样。任何帮助都将不胜感激

以下是我的index.js代码:

const config = require('config');
try {
    const myKey = config.get("jwtPrivateKey");
    debug(myKey);
} catch (error) {
    debug(error, "FATAL ERROR: jwtPrivateKey is not defined.");
   return process.exit(1);
}
custom-environment-variables.json:

{
    "jwtPrivateKey": "vidlyPrivateKey"
}

这是因为文件的命名应该在
config
文件夹中,名称为
default.json
config/default.json


这些是文档。

我有一个配置文件夹。我尝试将属性/值放入default.json文件中。我仍然收到相同的错误消息。