Search code examples
babeljsnode-inspector

How to debug babelJS transpiled code using node-inspector?


I am trying to use node-inspector debug a nodeJS app running with babel-node.

babel-node index.js --debug

Node-inspector works but it shows the source maps in the transpiled es5 instead of es6

enter image description here


Solution

  • It needs a wrapper that will create the source map to the source code instead of the transpiled code.

    From https://babeljs.io/docs/setup/#babel_node_debug

    npm install -g babel-node-debug
    babel-node-debug index.js
    

    Update

    Instead of running it with babel-node I transpile it to es5 + sourcemaps and then run it with node. By doing that, node-inspector will show the proper code in the source dev tools.

    I haven't figured out how to do it with babel-node