作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以这是我的 VS 代码 launch.json
文件:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4321",
"port": 9222,
"webRoot": "${workspaceFolder}"
}
]
}
npm start
调试开始前的命令,即运行开发服务器,然后启动 Chrome 实例并导航到提供的 url。
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"start"
]
Attribute runtimeExecutable does not exist ('npm')
最佳答案
找到解决方案:我需要一个 preLaunchTask
launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost",
...
// This runs dev server before debugger
"preLaunchTask": "start-dev-server",
}
]
}
tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"label": "start-dev-server",
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "npm",
"background": {
"activeOnStart": true,
"beginsPattern": ".*",
"endsPattern": "Finished.+"
},
"pattern": {
"regexp": "",
}
}
},
]
}
关于debugging - VSCode : Automatically run npm script on starting debugging of a web project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59509689/
我是一名优秀的程序员,十分优秀!