首页 > 解决方案 > 在配置目录中找不到配置。主要问题是我无法更改目录

问题描述

const express = require("express");
const app = express();
const config = require('config');
console.log('application name :' + config.get('name'));

我已经尝试过这种方法,但错误总是相同的。

process.env["NODE_CONFIG_DIR"] = "C:\Users\ghana\Desktop\Node\express-demo\config";

这是我得到的错误。

WARNING: No configurations found in configuration directory:/express-demo/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
C:\Users\ghana\Desktop\Node\node_modules\config\lib\config.js:182
    throw new Error('Configuration property "' + property + '" is not defined'); 

标签: node.jsexpressconfig

解决方案


推荐阅读