debugging - 需要 Visual Studio 代码配置来调试模板

标签 debugging visual-studio-code stenciljs

我正在使用此处找到的模板启动项目 ( 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 错误消息:

无法连接到运行时进程,10000 毫秒后超时 - (原因:无法连接到目标:404 文件未找到 网址:/json 文件:C:/work/projectA/www/json)。

最佳答案

Stencil 应用程序的 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 就会自动中断。

关于debugging - 需要 Visual Studio 代码配置来调试模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53540548/

相关文章:

c++ - 为什么我可以使用 for 循环而不是单独访问 C++ map 元素?

regex - VSCode : TextMate Regex in User Settings

javascript - VS Code 中来自具有导入的类型定义的 javascript 文件的智能感知

c - 在 vs code 中哪里添加 -g 标志以进行调试

ionic-framework - Stencil.js 呈现插槽内容,如果 render() 返回 null 则事件

用于比较 tarball、SRPM 和源代码文件的 Linux 软件

debugging - 两个程序对象运行时比较的方法

c - 也许资源没有释放?什么可能导致这种情况?

css-animations - Tailwind UI 过渡和变换

javascript - 如何测试 stenciljs 嵌套组件