Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug es6 transpiled code using node-inspector or babel-node-debug

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?

like image 878
user2670996 Avatar asked Oct 18 '22 14:10

user2670996


1 Answers

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

like image 178
Arlo Armstrong Avatar answered Oct 21 '22 06:10

Arlo Armstrong