Reputation:
I created a test project using npm init
and installed TypeScript. Now I want Visual Studio to use nodemon
for live re-attach of our debugger. According to the doc, it was installed globally using npm install -g nodemon
. Now I see the template when trying to add a new launch.json
configuration and the following config was added:
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "nodemon",
"program": "${workspaceFolder}/dist/index.js",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
I also tried to go directly on the typescript files by using
"program": "${workspaceFolder}/index.ts",
"outFiles": [
"${workspaceRoot}/dist/*.js"
]
The debugging works, breakpoints were reached. But it has a big problem: After about ~10 seconds of debugging, I get the following error message:
Cannot connect to runtime process, timeout after 10000ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:30792.)
What's the problem here? I exactly followed the documentation but couldn't make it work properly.
I only found some topics about old NodeJS versions in legacy mode. But I'm using a new one (v8.9.4) on Windows 7.
Upvotes: 5
Views: 2845
Reputation: 591
Had the same error and took me a while to solve it, here's my settings which eventually worked.
package.json
"scripts": {
"start": "node --inspect -r ts-node/register src/server.ts",
"dev": "./node_modules/nodemon/bin/nodemon.js",
"test": "jest",
"test:watch": "jest --watch"
}
nodemon.json
{
"ignore": ["**/*.test.ts", "**/*.spec.ts", ".git", "node_modules"],
"watch": ["src"],
"exec": "npm start",
"ext": "ts, gql",
"inspect": true,
"events": {
"restart": "echo \"[Warning] Remember run npm run test b4 push to dev branch !\""
}
}
launch.json
{
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 9229,
"restart": true,
"protocol": "inspector",
// "processId": "${command:PickProcess}",
"address": "localhost"
}]
}
Upvotes: 1