通过visual studio代码launch.json运行工头开始 [英] Running foreman start through visual studio code launch.json

查看:25
本文介绍了通过visual studio代码launch.json运行工头开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在通过在命令行中键入 foreman start 来运行我的解决方案,并且运行良好.我正在尝试使用 Visual Studio 代码调试我的代码.为此,我创建了一个 launch.json 文件:

Currently, I am running my solution by typing foreman start into the command line and that is working fine. I'm trying to debug my code using visual studio code. In order to do so, I have created a launch.json file:

{
    "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 文件来尝试从那时开始启动程序:

I have created a tasks.json file to try to start the program from that point:

{
    "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 时,我看到这个输出:

When I run foreman start normally, I see this output:

$ 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

如果我在当前状态下调试,控制台的输出是:

If I debug in this current state, the output from the console is:

Failed to launch external program start --no-color.
spawn start ENOENT

如果我将程序更改为指向 gulp:

If I change my program to point to gulp:

"program": "${workspaceRoot}/node_modules/.bin/gulp",

它给了我一些更有希望的东西,但因为它不是工头,它不能运行我需要的一切.

It gives me something a little more promising, but because it isn't foreman, it doesn't run everything I need.

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?

Does anyone know how to debug foreman start from visual studio code?

推荐答案

这会将 foreman start 作为 shell 命令运行.按F1,输入Run Task回车,然后选择development task.

This will run foreman start as shell command. Press F1, type Run Task, Enter and select development task.

{
    "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"

If you want to debug a web application you should take a look at vscode-chrome-debug if it is a node application you have to set the entry point of your app as program in launch.json "program": "${workspaceRoot}/app.js"

这篇关于通过visual studio代码launch.json运行工头开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆