2017-04-26 110 views
1

我是NodeJS和NPM的新手。“npm start”显示“未处理的承诺拒绝”错误

当我一个项目的NodeJS中运行npm start,出现如下错误:

Starting the development server... 

(node:9417) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with code 3 

这个错误是什么意思? 如何调试这个问题?

$ grep start package.json 
    "start": "react-scripts start", 

$ npm -v 
3.10.10 
$ node -v 
v6.10.1 

$ npm ls react-scripts 
[email protected] /home/li/sample 
└── [email protected] 

回答

0

我猜你的代码像下面

new Promise(function(resolve, reject){ 
    reject(0) 
}).then() 

当你运行上面的代码,你会得到“未处理的承诺拒绝”。

with Promise/A + standard #point-21。承诺必须提供当时的方法来获取其当前或最终的价值或原因。

你最好写代码如下

promise.then(onFulfilled, onRejected) 

其他方式来避免这个问题,你可以听的unhandledRejection事件与过程

​​
+0

有没有办法知道这个错误来自?代码中有很多'reject()'。我不确定哪一个导致错误。 – Xin

相关问题