nodemon -v: 1.19.0node -v: 12.0nodemon --inspect=0.0.0.0:9229 -r tsconfig-paths/register -r ts-node/register/type-check ./src/main.tsThe --inspect flag correctly passed to the node executable.
The --inspect flag passed to the ts-node executable but ts-node doesn't support that flag.
Created from PR https://github.com/remy/nodemon/pull/1552#issuecomment-489697831
This is related to #1564.
I don't use typescript at all, so you'll need to walk me through this. What is it in your command (assuming you're using node and not nodemon): --inspect=0.0.0.0:9229 -r tsconfig-paths/register -r ts-node/register/type-check ./src/main.ts that makes the .ts file compile as typescript?
This happens for me with node 10.15. If a launch a file ending with .ts in vscode, nodemon attempts to use ts-node instead of node. But vscode appends --inspect-brk arg:
starting `ts-node -r ts-node/register --inspect-brk=8917 /Users/dino/Development/better-ts/src/index.ts`
/Users/dino/Development/better-ts/node_modules/arg/index.js:92
throw err;
^
Error: Unknown or unexpected option: --inspect-brk
Our workaround was to edit the vscode launch config and override nodemon's default file mapping to force node to be used (last two lines):
...
"args": ["${workspaceFolder}/src/index.ts"],
"runtimeArgs": [
"-r",
"ts-node/register",
"--exec",
"node"
],...
Open question: should nodemon drop the (newly added) default mapping for .ts files?
Or is there another solution?
Is it _just_ --inspect that could cause this problem in user workflow? Because if it is, then the mapping could be done conditionally (as I think the old .coffee handling is done using conditional logic).
Adding my use case, this is my command:
nodemon --inspect=0.0.0.0:9229 --exec 'ts-node src/index.ts'
Which outputs:
[nodemon] starting `ts-node src/index.ts --inspect=0.0.0.0:9229`
I did have some luck with the following:
nodemon --exec 'node --inspect=0.0.0.0:9229 --require ts-node/register src/index.ts'
Which attaches the debugger as expected. Seems like more of an issue with ts-node than with nodemon itself. I'm also having issues with breakpoints matching up with the lines, but that's definitely not a nodemon issue.
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3
Hi @remy. Thanks for your work on nodemon!
I'd prefer to have the option to specify exactly which modules node will require.
I think it would be reasonable to automatically add --require ts-node/register for .ts files only if no --require args are provided to nodemon. This would make nodemon easier to use with typescript files, but without getting in the way of more customised setups.
I don't use typescript at all, so you'll need to get a PR in with some
consensus if this makes sense.
On Thu, 6 Jun 2019, 15:39 taye, notifications@github.com wrote:
Hi @remy https://github.com/remy. Thanks for your work on nodemon!
I'd prefer to have the option to specify exactly which modules node will
require.I think it would be reasonable to automatically add --require
ts-node/register for .ts files only if no --require args are provided to
nodemon. This would make nodemon easier to use with typescript files, but
without getting in the way of more customised setups.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/remy/nodemon/issues/1565?email_source=notifications&email_token=AAADLBDBCEJXKFM6X5JBFTDPZEORNA5CNFSM4HLB2PQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXDB2OQ#issuecomment-499522874,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAADLBBZ6HGMAEVCZOIBSOTPZEORNANCNFSM4HLB2PQQ
.
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3
boop
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3
Adding my use case, this is my command:
nodemon --inspect=0.0.0.0:9229 --exec 'ts-node src/index.ts'Which outputs:
[nodemon] starting `ts-node src/index.ts --inspect=0.0.0.0:9229`I did have some luck with the following:
nodemon --exec 'node --inspect=0.0.0.0:9229 --require ts-node/register src/index.ts'Which attaches the debugger as expected. Seems like more of an issue with ts-node than with nodemon itself. I'm also having issues with breakpoints matching up with the lines, but that's definitely not a nodemon issue.
worked for me
Another option is using execMap in package.json:
json
"nodemonConfig": {
"execMap": {
"ts": "node --require ts-node/register/transpile-only"
}
}
Now nodemon --inspect-brk=9229 src/example.ts runs node --require ts-node/register/transpile-only --inspect-brk=9229 src/example.ts.
Most helpful comment
Adding my use case, this is my command:
Which outputs:
I did have some luck with the following:
Which attaches the debugger as expected. Seems like more of an issue with ts-node than with nodemon itself. I'm also having issues with breakpoints matching up with the lines, but that's definitely not a nodemon issue.