I am new to NodeJS and NPM.
When I run npm start within a NodeJS project, the following errors occurred:
Starting the development server...
(node:9417) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with code 3
What does this error mean? How should debug this problem?
$ 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
I guess your code like below
new Promise(function(resolve, reject){
reject(0)
}).then()
when you run the code above, you will get “Unhandled promise rejection”.
with Promise/A+ standard #point-21. A promise must provide a then method to access its current or eventual value or reason.
you'd better write code as below
promise.then(onFulfilled, onRejected)
the other way to avoid the issue, you can listen the unhandledRejection event with process
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
});