Debug es6 transpiled code using node-inspector or

2019-05-03 11:50发布

When I debug my node rest api, I try to use node-inspector

node-inspector

node --debug server.js

This way I can debug my api using localhost:3000/api... If I use node-debug, there's no way. It doens't start port 3000.

However my code is ES6, so in my current debug my code is transpiled by Babel.

I've tried to use babel-node-debug but It seems too be the same situation I had with node-debug. I can see ES6 code, but I'm not able to debug through port 3000.

Any workaround?

1条回答
【Aperson】
2楼-- · 2019-05-03 12:21

The options for babel-node (included in the babel-cli package) are the same as for node.

  1. Specify the port for babel-node

babel-node --debug-brk=8010 test.js

  1. Start node-inspector

node-inspector

  1. Navigate to the node-inspector URL, passing the same port as a query parameter

http://127.0.0.1:8080/?port=8010

I have tried this and it works well for me.

Disclaimer - I found this information here: https://github.com/CrabDude/babel-node-debug/issues/6

查看更多
登录 后发表回答