Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode调试Egg.js项目 #1

Open
NewBrandSTONE opened this issue Nov 4, 2017 · 0 comments
Open

VSCode调试Egg.js项目 #1

NewBrandSTONE opened this issue Nov 4, 2017 · 0 comments
Labels

Comments

@NewBrandSTONE
Copy link
Owner

设置断点

首先,在需要调试的地方打好断点

断点示例

如上图,点击左侧的行数,158行就可以打上断点了

配置launch.json文件

1. 进入调试窗口

点击vscode左侧的debug窗口,如果你之前没有配置过launch.json文件,那么现实效果就会如下图一样。

调试窗口禅师

2. 新建launch.json配置文件

点击左上方,【没有配置】,添加配置

VSCode本身就内置了Node.js的调试工具,如果将来你需要调试别的东西,可以在这里选择添加对应的调试插件工具。

添加Node.js配置

这里我们调试的是Node.js,就选择Node.js,然后VSCode会在/.vscode目录中新建一个launch.json文件

3. 配置launch.json文件

launch.json文件新建好后,我们需要进行一些配置操作,这里我们选择的是,附加到进程。

后面我们是先启动egg的调试进程,然后再将vscode附加到进程中的。

配置VScode的Attach

这里有一个很关键的节点,program这个属性写的就是你需要调试的js文件,我这边调试的是刚才打上断点的文件pledges.js

选择需要调试的js文件

4. 开启egg的调试模式

使用iterm进入到工程目录,开启调试模式

npm run dev --debug

用调试模式启动项目

在VSCode中选择Attach to Process,并且选择egg-cluster这个进程。

选择egg-cluster这个线程

等请求进入到刚才打断点的地方,VSCode就会自己跳转到调试点啦,然后就可以尽情调试啦~

debugger中

BTW,如果你有更好,更简单的调试方式请告诉我...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant