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