运行 工头通过 visual studio 代码开始 launch.json
Running foreman start through visual studio code launch.json
目前,我正在通过在命令行中键入 foreman start
来 运行 解决我的解决方案,并且工作正常。我正在尝试使用 visual studio 代码调试我的代码。为此,我创建了一个 launch.json 文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/package.json",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "start",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
我已经创建了一个 tasks.json 文件来尝试从该点启动程序:
{
"version": "0.1.0",
"command": "start",
"isShellCommand": true,
"args": [
"--no-color"
],
"tasks": [
{
"taskName": "test",
"args": [],
"isTestCommand": true
},
{
"suppressTaskName": true,
"taskName": "start",
"args": [
"foreman",
"start"
],
"isBuildCommand": true
}
]
}
当我 运行 foreman start
正常时,我看到这个输出:
$ foreman start
12:00:59 web.1 | started with pid 22641
12:00:59 workers.1 | started with pid 22642
12:00:59 intermediary.1 | started with pid 22643
12:01:00 web.1 | [INFO] Node app is running at localhost: 3777
如果我在当前状态下调试,控制台的输出是:
Failed to launch external program start --no-color.
spawn start ENOENT
如果我将程序更改为指向 gulp:
"program": "${workspaceRoot}/node_modules/.bin/gulp",
它给了我一些更有希望的东西,但因为它不是工头,所以它不能 运行 我需要的一切。
node --debug-brk=16751 --nolazy node_modules/.bin/gulp
Debugger listening on port 16751
[16:23:17] Using gulpfile ~/Git/backend/gulpfile.js
[16:23:17] Starting 'watch'...
[16:23:18] Finished 'watch' after 125 ms
[16:23:18] Starting 'default'...
[16:23:18] Finished 'default' after 13 μs
有人知道如何从 visual studio 代码调试 foreman start
吗?
这将 运行 foreman start
作为 shell 命令。按 F1,键入 Run Task
, 输入 和 select development
任务。
tasks.json
{
"version": "0.1.0",
"command": "foreman",
"isShellCommand": true,
"tasks": [
{
"suppressTaskName": true,
"taskName": "development",
"args": [
"start"
],
"isWatching": true
}
]
}
如果您想调试 Web 应用程序,您应该查看 vscode-chrome-debug 如果它是节点应用程序,您必须将应用程序的入口点设置为 launch.json 中的程序 "program": "${workspaceRoot}/app.js"
目前,我正在通过在命令行中键入 foreman start
来 运行 解决我的解决方案,并且工作正常。我正在尝试使用 visual studio 代码调试我的代码。为此,我创建了一个 launch.json 文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/package.json",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "start",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
我已经创建了一个 tasks.json 文件来尝试从该点启动程序:
{
"version": "0.1.0",
"command": "start",
"isShellCommand": true,
"args": [
"--no-color"
],
"tasks": [
{
"taskName": "test",
"args": [],
"isTestCommand": true
},
{
"suppressTaskName": true,
"taskName": "start",
"args": [
"foreman",
"start"
],
"isBuildCommand": true
}
]
}
当我 运行 foreman start
正常时,我看到这个输出:
$ foreman start
12:00:59 web.1 | started with pid 22641
12:00:59 workers.1 | started with pid 22642
12:00:59 intermediary.1 | started with pid 22643
12:01:00 web.1 | [INFO] Node app is running at localhost: 3777
如果我在当前状态下调试,控制台的输出是:
Failed to launch external program start --no-color.
spawn start ENOENT
如果我将程序更改为指向 gulp:
"program": "${workspaceRoot}/node_modules/.bin/gulp",
它给了我一些更有希望的东西,但因为它不是工头,所以它不能 运行 我需要的一切。
node --debug-brk=16751 --nolazy node_modules/.bin/gulp
Debugger listening on port 16751
[16:23:17] Using gulpfile ~/Git/backend/gulpfile.js
[16:23:17] Starting 'watch'...
[16:23:18] Finished 'watch' after 125 ms
[16:23:18] Starting 'default'...
[16:23:18] Finished 'default' after 13 μs
有人知道如何从 visual studio 代码调试 foreman start
吗?
这将 运行 foreman start
作为 shell 命令。按 F1,键入 Run Task
, 输入 和 select development
任务。
tasks.json
{
"version": "0.1.0",
"command": "foreman",
"isShellCommand": true,
"tasks": [
{
"suppressTaskName": true,
"taskName": "development",
"args": [
"start"
],
"isWatching": true
}
]
}
如果您想调试 Web 应用程序,您应该查看 vscode-chrome-debug 如果它是节点应用程序,您必须将应用程序的入口点设置为 launch.json 中的程序 "program": "${workspaceRoot}/app.js"