NodeJS 6:如何查看整个错误堆栈跟踪?
而不是在编译/运行时得到承诺拒绝警告
npm start (node:22996) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected identifier
我可以得到整个堆栈跟踪指出我的代码中的行与在nodejs 4中使用的错误?
SyntaxError: /Users/user/Documents/project/app.js: Unexpected token (30:57)
将下面的代码添加到您的代码中,以获得您所期望的堆栈跟踪:
process.on('unhandledRejection', r => console.error(r));
它会显示错误代码行。