gpt4 book ai didi

debugging - VSCode : Automatically run npm script on starting debugging of a web project

转载 作者:行者123 更新时间:2023-12-04 01:36:06 28 4
gpt4 key购买 nike

所以这是我的 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')

有什么帮助吗?

最佳答案

找到解决方案:我需要一个 preLaunchTasklaunch.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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com