Using grunt in launch.json

I downloaded the yeomen generator generator and opened it using Visual Studio code. The debugger works well. When I clicked on the debug sidebar button, the launch.json file was created for me. The launch.json generator is looking at package.json, which has one "scripts": { "start": "grunt"}.

The generator uses grunt to run the application. The launch.json file had the following:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "node",
            "request": "launch",
            "program": "grunt",
            "stopOnEntry": false,
            "args": [],
            "cwd": ".",
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development"
            },
            "externalConsole": false,
            "sourceMaps": false,
            "outDir": null
        },
        {
            "name": "Attach",
            "type": "node",
            "request": "attach",
            "port": 5858
        }
    ]
}

When I replace 'program' : 'grunt'with server.js, it works. If I could change the type to grunt, but it seems that only node or mono is supported there.

+4
source share
1 answer

I managed to get it working using the absolute path to grunt-cli, as shown below:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Grunt",
            "args": ["build"],            
            "program": "${env.APPDATA}\\npm\\node_modules\\grunt-cli\\bin\\grunt", 
            "stopOnEntry": true,
            "cwd": "${workspaceRoot}"
        }
    ]
}

@L.Butz, vscode env.APPDATA env:APPDATA.

+5

Source: https://habr.com/ru/post/1626372/


All Articles