tsc-watch: Restarting debugger after file change doesn't work

Hi,

I have the following configurations:

Package.json script:

"start-watch": "NODE_ENV=development ./node_modules/.bin/tsc-watch --onSuccess \"node --inspect bin/server/src/server.js\" --onFailure \"notify-send -a Node 'Transpilation error!' 'Check the task terminal for results...'\" -p ../tsconfig.dev.json"

Launch.json:

{
    "type": "node",
    "request": "launch",
    "name": "Launch via NPM",
    "runtimeExecutable": "npm",
    "runtimeArgs": [
        "run-script",
        "start-watch"
    ],
    "env": {
        "NODE_ENV": "development"
    },
    "port": 9229,
    "skipFiles": [
        "<node_internals>/**"
    ],
    "outputCapture": "std", // Necessary to be able to see logging in the debug console
    "restart": true,
},
{
    "type": "node",
    "request": "attach",
    "name": "Attach to running node",
    "port": 9229,
    "restart": true,
}

I was hoping that using the "restart": true config as described here in the VSCode docs would work with tsc-watch, but that doesn’t appear to be the case. It looks like the watcher rebuilds, but not restart the node server. I can observe in the logs that the watcher started the transpilation; since it outputs the start and finish message.

Am I misconfiguring something here, or is this scenario (restarting and re-attaching the debugger from launch.json) not supported? Note that manually invoking the start-watch and then attaching using the second launch configuration does work across restarts. It’s just when I invoke the NPM script via launch.json that it doesn’t work.

Thank you for your time.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

ok, I found the issue (Pushed to the repo) You must use this: "console": "integratedTerminal" to be able to use restart…