1

I'm trying to debug my node + babel project with VScode without success. I read a lot of answers no one fixed my problem. How should launch.json look alike?

I want to be able to attach the debugger to a running process and launch the program.

Package.json

"build-babel": "npx babel src -d dist",
        "start": "node dist/server.js",
        "dev-start": "nodemon --inspect-brk --exec babel-node ./src/server.js",

First try from: Can Visual Studio Code be configured to launch with nodemon

launch.json

    {
      "type": "node",
      "request": "launch",
      "name": "Nodemon",
      "runtimeExecutable": "${workspaceRoot}/node_modules/nodemon/bin/nodemon.js",
      "args": [
        "${workspaceRoot}/src/server.js"
      ],
      "restart": true,
      "protocol": "inspector",
      "stopOnEntry": true,
    },
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to app",
      "port": 9229,
      "address": "localhost",
      "sourceMaps": true,
      "smartStep": true,
      "restart": true
    },

update

I also tried this:

    {
      "type": "node",
      "request": "launch",
      "name": "nodemon",
      "runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
      "program": "${workspaceFolder}/src/server.js",
      "restart": true,
      "console": "integratedTerminal",
      "port": 9229,
      "args": ["--exec", "babel-node", "--babel-preset-es2015"],
      "internalConsoleOptions": "neverOpen"
    }

run it when there is a server process running from a terminal: attached but the breakpoints don't got hit "set but not yet bound"

The launch process result error: Cannot connect to runtime process- reason: connot connect to the target: connect econnrefused 127.0.0.1:9229

Thank you

DonSaada
  • 767
  • 2
  • 8
  • 18
  • Duplicated question, check this out: https://stackoverflow.com/questions/34450175/can-visual-studio-code-be-configured-to-launch-with-nodemon – koFTT May 28 '19 at 13:02
  • @koFTT Thank you for your answer I already tried this: ```javascript { "type": "node", "request": "launch", "name": "nodemon", "runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js", "program": "${workspaceFolder}/src/server.js", "restart": true, "console": "integratedTerminal", "port": 9229, "args": ["--exec", "babel-node", "--babel-preset-es2015"], "internalConsoleOptions": "neverOpen" } ``` – DonSaada Jun 02 '19 at 09:31
  • Possible duplicate of [Can Visual Studio Code be configured to launch with nodemon](https://stackoverflow.com/questions/34450175/can-visual-studio-code-be-configured-to-launch-with-nodemon) – koFTT Jun 03 '19 at 16:29
  • @koFTT, please see the first message, I already tried this solution with no success \= – DonSaada Jun 04 '19 at 11:50
  • I may be able to help you... i'll only ask one question here, and depending your answer i'll post a satisfying (i hope) answer. The question: Are you by any chance trying to run an express server? – Tal Kohavy Oct 22 '22 at 13:29

0 Answers0