Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using grunt in launch.json

I loaded the yeoman generator-meanjs and opened it with Visual Studio Code. The debugger works nicely. When I clicked on the debug side bar button a launch.json file was generated for me. The launch.json generator is looking at the package.json which has "scripts": { "start": "grunt"}.

The generator uses grunt to launch 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 only node or mono is supported there.

like image 292
matthewbaskey Avatar asked Jan 28 '16 15:01

matthewbaskey


People also ask

How do I install grunt in task runner?

Like installing a specific version of grunt, run npm install grunt@VERSION --save-dev where VERSION is the version you need, and npm will install that version of Grunt in your project folder, adding it to your package.

How do I run local grunt?

Installing grunt-cli locally js method to get started with a project ( npm install && npm test ) then install grunt-cli locally with npm install grunt-cli --save-dev . Then add a script to your package. json to run the associated grunt command: "scripts": { "test": "grunt test" } .


1 Answers

I managed to make it work by using an absolute path to grunt-cli, as follows:

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

As pointed by @L.Butz, on newer vscode versions, replace env.APPDATA by env:APPDATA.

like image 180
darksoulsong Avatar answered Sep 20 '22 12:09

darksoulsong