You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Specify a different tsconfig when launching debugger in VS Code #734
C:\Program Files\nodejs\node.exe: bad option: --project ../../scripts/tsconfig.json
On the other hand, if I omit the --project part and only have
"args": ["scripts/precompile.ts"],
then the command fails with the same error that I would get if I omitted --project on the commandline. The error is
import fs from 'fs-extra';
^^
SyntaxError: Unexpected identifier
and results from my top-level tsconfig.json targeting a different type of module -- which is why I created the separate tsconfig in the first place, for tsnode's usage.
Is there any way to pipe this through to the VSCode launch config?
You need to use environment variables for this. Node.js doesn't understand ts-node arguments directly, so we have a "backdoor" via environment variables. In VS Code, you can set environment variables through the launch.json. There's some (not great) documentation in https://code.visualstudio.com/Docs/editor/debugging, I think it should look something like: "env": { "TS_NODE_PROJECT": "path-here" } (not tested).
Reacted by xx, Ionel lupu, TuNA, Igor Milenković and Andrei Gaspar
Yep, that worked beautifully! Thanks, @blakeembrey! Added PR #738 to make a note of this in the readme, if you think that would be useful to have there.
Activity
blakeembrey commentedon Nov 23, 2018
You need to use environment variables for this. Node.js doesn't understand
ts-nodearguments directly, so we have a "backdoor" via environment variables. In VS Code, you can set environment variables through thelaunch.json. There's some (not great) documentation in https://code.visualstudio.com/Docs/editor/debugging, I think it should look something like:"env": { "TS_NODE_PROJECT": "path-here" }(not tested).Zlatkovsky commentedon Nov 27, 2018
Yep, that worked beautifully! Thanks, @blakeembrey! Added PR #738 to make a note of this in the readme, if you think that would be useful to have there.