美文网首页我爱编程
使用 config-lite读取config文件 (node:6

使用 config-lite读取config文件 (node:6

作者: 樱yuan | 来源:发表于2018-06-08 11:26 被阅读0次

在弄项目的时候终端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

相关文章

网友评论

    本文标题:使用 config-lite读取config文件 (node:6

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