node学习笔记(五):调试|vscode

一、node官网调试工具

Chrome DevTools 55+

  • Option 1: Open chrome://inspect in a Chromium-based browser. Click the Configure button and ensure your target host and port are listed.
  • Option 2: Copy the devtoolsFrontendUrl from the output of /json/list (see above) or the --inspect hint text and paste into Chrome.(默认有9229,chrome里面配置好的,我的电脑没有加配置)

>node --inspect --debug-brk 05_dubugger.js

执行上面语句

F:\my_workspace\node_study>node --inspect --debug-brk 05_dubugger.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
    chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/761d904f-93a8-496e-a081-56e6290b3340

打开chrome

node学习笔记(五):调试|vscode

 二、ide调试

上面的方式没办法预先打断点,所以在ide里面调试方便

因为我目前用的是WebStorm(我可以直接打断点,调试),视频里用的是 VSCode。

所以我需要先了解一下这两个ide的区别:

去查了一下,vscode比较轻量,插件也多,更多的是面向未来的编程,对于webStorm是更多的可配置,稳定性强,应该再加一个重构性强吧。所以我还是不换了 , 因为我的java开发用的idea,他们家族的产品挺好用的,php学习的时候也是用的他们家的产品(phpStorm)。算了,我不换了。

node学习笔记(五):调试|vscode

vsCode可以条件断点调试,查了一下,webstorm好像是不可以的!不过条件断点真的是挺方便的,看看如果vscode还有我更喜欢的功能,我就安装到电脑上。