我是NodeJS和NPM的新手。
当我在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
reference-apps@2.3.1 /home/li/sample
└── react-scripts@0.5.1 发布于 2017-04-26 15:10:32
我猜您的代码如下所示
new Promise(function(resolve, reject){
reject(0)
}).then()当你运行上面的代码时,你会得到“未处理的承诺拒绝”。
使用Promise/A+标准#point-21。promise必须提供then方法来访问其当前或最终的值或原因。
你最好像下面这样写代码
promise.then(onFulfilled, onRejected)避免这个问题的另一种方法是用process监听unhandledRejection事件
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
}); https://stackoverflow.com/questions/43625615
复制相似问题