Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Gulp nodemon with the VSCode inspector. #148

Open
anxious-coder-lhs opened this issue Jan 30, 2018 · 2 comments
Open

Using Gulp nodemon with the VSCode inspector. #148

anxious-coder-lhs opened this issue Jan 30, 2018 · 2 comments

Comments

@anxious-coder-lhs
Copy link

I am trying to figure out the VSCode launch configuration for launching a gulp task in the inspect mode. The gulp task internally transpiles the code and runs the process via gulp-nodemon. Example is given as below:

VSCode Launch script:

 {
            "type": "node",
            "request": "launch",
            "name": "Gulp App debug",
            "program": "${workspaceRoot}\\node_modules\\gulp\\bin\\gulp.js",
            "args": [
                "serve:dev"
            ],
            "sourceMaps": true,
            "outputCapture": "std"            
        },

Gulp Task:

gulp.task("serve:dev", ["release"], () => {
  const through = require("through2");
  const nodemon = require("gulp-nodemon");
  const nodemonStream = nodemon({
    script: "dist/src/app.js",
    ext: "",
    exec: 'node --inspect',
    // nodeArgs: ['--inspect'],
    watch: "none", // Disabled, will be triggered externally.
    env: Object.assign(process.env, {
      LOG_LEVEL: "debug",
      EXEC_MODE: "dev",
      NODE_PATH: "dist/src"
    })
  });

const watchSrc = watch("./src/**/*", vinyl => {
    return compileSourcesStream(
      gulp.src(vinyl.path),
      gulp.dest("dist/src")
    ).pipe(
      through.obj(function(chunk, enc, cb) {
        nodemonStream.emit("restart");
        cb(null, chunk);
      })
    );

In the above configuration, the VSCode launches the gulp task with the inspect mode binding to a random port. However the gulp task itself runs the nodemon with the inspect mode pointing to a different new random port. This leads to VSCode unable to track the launched process.

Any suggestion on the above setup ?

@techsin
Copy link

techsin commented Sep 3, 2018

same problem

@roblourens
Copy link

You can set a port like exec: 'node --inspect=9229',, then set the same port in your launch config: "port": 9229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants