主要分为以下三个步骤
-
安装 debug for chrome
-
配置 launch.json 文件
配置内容如下
{ "version": "0.2.0", "configurations": [{ "type": "chrome", "request": "launch", "name": "Launch Chrome", "url": "http://localhost:3000", // 改为目标 url "sourceMaps": true, "webRoot": "${workspaceFolder}", "skipFiles": [ "node_modules/**" ], "sourceMapPathOverrides": { "webpack:///*": "${webRoot}/*" } }] }
3 使用 npm 启动项目, 关掉弹出的浏览器页面
4 打断点,在 Debug 模块启动调试