NodeJS 6: How to view the entire trace of the error stack?

Instead of receiving a warning about the refusal of the promise at compilation / start

npm start

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

can I get the whole stack trace indicating a line in my code with an error like it was in nodejs 4?

SyntaxError: /Users/user/Documents/project/app.js: Unexpected token (30:57)
+4
source share
1 answer

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

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

It will show you a line of code with an error.

+3
source

Source: https://habr.com/ru/post/1667618/


All Articles