25

I stareted my node app with node index.js and got the following message:

(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)

Now I'm interessted in whats happening. I've seen that there are mapping files TronWeb.node.js.map in the tronweb\dist directory. I started again using --inspect and opened the chrome dev tools. But in the console I see exactly the same message.

2 Answers 2

51

In Node v12.12.0+ sourcemaps are supported natively. Pass --enable-source-maps flag to enable them.

One caveat in Node v12.12.0 is that Error.prepareStackTrace will no longer be called when source maps are enabled. This was fixed in v12.16+.

3
  • 11
    passing it in an environment variable also works NODE_OPTIONS=--enable-source-maps node
    – user3064538
    Commented Mar 29, 2022 at 5:55
  • 1
    Please note that this is an experimental flag and has some reported performance issues. Commented Jul 12, 2022 at 20:01
  • 1
    I tried for hours to understand why webpack's source map isn't working for me - this simple flag just solved it.. AMAZING!!
    – Yitzchak
    Commented Sep 8, 2022 at 21:31
8

You can use https://www.npmjs.com/package/source-map-support

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

Then change your run command in package.json to:

node -r source-map-support/register index.js

(Note that you should have an index.map.js next to index.js)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.