4

Instead of getting the promise rejection warning while compiling/running

npm start

(node:22996) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected identifier

can I get the whole stack trace pointing out the line in my code with the error as it used to in nodejs 4?

SyntaxError: /Users/user/Documents/project/app.js: Unexpected token (30:57)
njLT
  • 464
  • 6
  • 21

1 Answers1

5

Add the following to your code to get a stack trace as you expect:

process.on('unhandledRejection', r => console.error(r));

It will show you the line of code with the error.

Brendan Molloy
  • 1,784
  • 14
  • 22