简体   繁体   English

使用node-inspector或babel-node-debug调试es6转换代码

[英]Debug es6 transpiled code using node-inspector or babel-node-debug

When I debug my node rest api, I try to use node-inspector 当我调试我的节点rest api时,我尝试使用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. 这样我就可以使用localhost:3000 / api调试我的api ......如果我使用node-debug,那就没办法了。 It doens't start port 3000. 它不会启动端口3000。

However my code is ES6, so in my current debug my code is transpiled by Babel. 但是我的代码是ES6,所以在我目前的调试中,我的代码由Babel编译。

I've tried to use babel-node-debug but It seems too be the same situation I had with node-debug. 我试过使用babel-node-debug但是看起来我和node-debug的情况差不多。 I can see ES6 code, but I'm not able to debug through port 3000. 我可以看到ES6代码,但我无法通过端口3000进行调试。

Any workaround? 任何解决方法?

The options for babel-node (included in the babel-cli package) are the same as for node . babel-node (包含在babel-cli包中)的选项与node相同。

  1. Specify the port for babel-node 指定babel-node的端口

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

  1. Start node-inspector 启动node-inspector

node-inspector

  1. Navigate to the node-inspector URL, passing the same port as a query parameter 导航到node-inspector URL,将相同的端口作为查询参数传递

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 免责声明 - 我在此处找到了这些信息: https//github.com/CrabDude/babel-node-debug/issues/6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM