nodemon -v: 1.14.12node -v: 8.9.4ts-node -v: 4.1.0nodemon with the following nodemon.json:
{
"verbose": true,
"watch": [
"src"
],
"ext": "ts",
"exec": "{{pwd}}/node_modules/.bin/ts-node ./src/index.ts --project ./tsconfig.development.json --inspect=5858 --inspect-brk"
}
--inspect=5858 --inspect-brk are passed to node and one can connect with debugger
--inspect=5858 --inspect-brk are not passed to node and one can't connect with debugger
terminal output:
[nodemon] 1.14.12
[nodemon] reading config .\nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 22156 to restart
[nodemon] watching: C:\Dev\node-typescript-vscode\src/**/*
[nodemon] watching extensions: ts
[nodemon] starting `C:\Dev\node-typescript-vscode/node_modules/.bin/ts-node ./src/index.ts --project ./tsconfig.development.json --inspect=5858 --inspect-brk`
[nodemon] spawning
[nodemon] child pid: 11272
[nodemon] watching 2 files
yarn install or npm installyarn run serve:debug or npm run serve:debugAttach to nodemon VS Code debug configurationContinuation of discussion of remy/nodemon#1250 and specifically https://github.com/remy/nodemon/issues/1250#issuecomment-364084892.
Yes, I was going crazy for a file. I thought it was just me. Actually, I am also running nodemon but I took this out of the equation. So I execute
ts-node ./src/index.ts --inspect-brk=5860
And the same thing, it never waits for the debugger to be attached and prints out to the console the console.log that I made. I also had a breakpoint on the console.log.
Sorry, probably worth mentioning that i am on a MAC
and
ts-node v4.1.0
node v8.9.1
typescript v2.7.1
Ok, I think i have a workaround
You can execute it like this
node --inspect-brk=5858 --require ts-node/register ./src/index.ts
so you can create your nodemon.json file and do this, (create multiple nodemon.json files if you like - I have 1 for inspect and 1 for inspect-brk)
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "node --inspect-brk=5858 --require ts-node/register ./src/index.ts"
}
Hope that helps.
So this trick here is not to run ts-node direct but to load via node.
@appsolutegeek Thanks for the workaround! Unfortunately it's not a complete solution because there's a case when third-party tools pass these args to the ending dynamically, e. g. Visual Studio Code debugger.
I'd recommend using node --require with flags. I'm going to deprecate this current usage, the hacks are just too taxing on me to maintain. Can you describe why that doesn't work for Visual Studio Code debugger?
Closing with https://github.com/TypeStrong/ts-node/pull/536. I recommend node -r ts-node/register for all advanced node.js use-cases and flags.
Most helpful comment
Closing with https://github.com/TypeStrong/ts-node/pull/536. I recommend
node -r ts-node/registerfor all advanced node.js use-cases and flags.