How to debug babelJS transpiled code using node-inspector?

cuadraman picture cuadraman · Sep 22, 2015 · Viewed 10.3k times · Source

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

Answer

Sushant Rao picture Sushant Rao · Mar 4, 2016

For babel 6, I used the require hook.

Follow these instructions to get babel register. https://babeljs.io/docs/setup/#babel_register

In your app.js or entrypoint to the application add

require('babel-register')({
  sourceMaps: true
});

If you need to add other options as well, see - https://babeljs.io/docs/usage/options/#options

You should be able to use node-inspector & chrome to to debug your application