使用 config-lite读取config文件 (node:6136) UnhandledPromiseRejectionWarning:

在弄项目的时候终端node报了一些错误   : 

(node:6136) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: URL malformed, cannot be parsed

(node:6136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

红色框中:Error: URL malformed, cannot be parsed

原因:   
    使用了config-lite模块读取config目录下面的配置,但在v2中,要指定config_basedir用于冒泡查找配置文件的目录。

解决方法:
    const config = require (' config-lite ');  改成  const config = require (' config-lite ')(__dirname );

npm上config-lite的地址 : https://www.npmjs.com/package/config-lite

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容