我正在使用在这里(https://github.com/ionic-team/stencil-component-starter)上找到的模板启动程序项目,我想在Visual Studio代码中调试代码。我尝试了以下配置,但它们都不起作用
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 3333,
"webRoot": "${workspaceFolder}"
},
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3333",
"sourceMaps": true,
"webRoot": "${workspaceFolder}"
}
]
启动版本的确可以成功启动chrome并显示正在运行的模具项目,但是Visual Studio代码中的所有断点都表示它们“未验证”,因此执行不止于此。附加的版本不起作用,它给我一条404错误消息,内容为:
Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: 404 File Not Found Url: /json File: C:/work/projectA/www/json).
在webRoot
一个模板的应用程序应该是${workspaceFolder}/www
。那应该修复launch
配置。
要附加,必须将其设置port
为Chrome调试端口,并使用标志进行设置。资料来源:https : //github.com/Microsoft/vscode-chrome-debug#attach
但是由于Stencil不会生成源映射,所以您将只能调试已编译的代码。资料来源:https : //github.com/ionic-team/stencil/issues/219
查找正确的生成文件的方法是添加一条debugger;
语句,以便VS Code自动中断。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句