node.js - 如何在 Node js 中使用源映射?

标签 node.js debugging node-inspector

我用 node index.js 启动了我的 Node 应用程序并收到以下消息:
(node:10128) UnhandledPromiseRejectionWarning: TypeError: e.reduce is not a function at Module.te (C:\Projects\myproject\node_modules\tronweb\dist\TronWeb.node.js:1:9236)
现在我对发生的事情很感兴趣。我看到有映射文件TronWeb.node.js.maptronweb\dist目录。我再次开始使用 --inspect并打开了 chrome 开发工具。但是在控制台中,我看到了完全相同的消息。

最佳答案

您可以使用 https://www.npmjs.com/package/source-map-support

$ npm install source-map-support --save-dev

然后将 package.json 中的运行命令更改为:
node -r source-map-support/register index.js

(注意你应该在 index.js 旁边有一个 index.map.js)

关于node.js - 如何在 Node js 中使用源映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53265182/

相关文章:

javascript - 使用 Google Home 或 Alexa 的 TTS

javascript - Nodenv 中的 x.x.x-rc Node.js 版本是什么?

javascript - 如何编译 Node.js 和 Angular

c# - 调试调用 .Net(C#) dll 的 VB6 项目

sql-server - 让 sp_tracegenerateevent 在存储过程中工作

c - ruby 1.8.7 : Segfault on calling function inside C extension

node.js - 项目: sahat/hackathon-starter: Error: ENOENT,没有这样的文件或目录

node.js - node-inspector --webhost 不是本地的!它是一个网络应用程序

javascript - 如何识别node.js缓冲区中的负数

javascript - 难以在 Node-Inspector 中设置断点