My issue is not working --project flag with nodemon.
For watching(detecting file changes) nodemon is needed.
But nodemon config and cli can not read ts-node flags including --project.
modemon.json
{
"restartable": "rs",
"ignore": [".git", "node_modules/**/node_modules"],
"verbose": true,
"execMap": {
"ts": "node --require ts-node/register src/server.ts --project tsconfig.server.json"
},
"watch": ["src/"],
"env": {
"NODE_ENV": "development"
},
"ext": "js,json,ts"
}
I want to compile ts-node withtsconfig.server.json instead of tsconfig.json.
tsconfig.json is a default config for ts-node but server.ts needs another typescript config because es5, commonjs syntax.
(in my project, tsconfig.json is for client compile)
How can I add --project flag to ts-node?
P.S.
if I change the order of cli,
node --require ts-node/register--project tsconfig.server.json src/server.ts
it crashed with node error
node: bad option: --project
try TS_NODE_PROJECT environment variable
https://github.com/TypeStrong/ts-node#cli-and-programmatic-options
@DylanJu Like @yi-fan-song mentions, --project is not an option for node - it's an option for ts-node. You can also change the executable with nodemon to be ts-node to get around this.
node --require ts-node/register is required when I want to use --inspect
So my question is,
how can I use both --inspect for debugging with Chrome and --project for setting my custom tsconfig.json
@blakeembrey can you plz take a look
You should be able to use our environment variables for this.
https://github.com/TypeStrong/ts-node#visual-studio-code
https://github.com/TypeStrong/ts-node#cli-and-programmatic-options
Same problem.
How do I setup enviroment variables when I use script from package.json?
"tsc3": "node -r ts-node/register ./src/index2.ts"
https://www.npmjs.com/package/cross-env
On Mon, May 4, 2020 at 6:57 PM DTX-92 notifications@github.com wrote:
Same problem.
How do I setup enviroment variables when I use script from package.json?
"tsc3": "node -r ts-node/register ./src/index2.ts"—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/TypeStrong/ts-node/issues/869#issuecomment-623750915,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAC35OHWN2DKE6ULRVAPOKDRP5B4XANCNFSM4INOOK7A
.
就像@ yi-fan-song提到的那样,@ DylanJu
--project不是一个选项node-它是一个选项ts-node。您还可以更改与可执行nodemon要ts-node来解决这个问题。
ts-node --script-mode main.ts
or
cross-env TS_NODE_PROJECT=<tsconfig.json> main.ts # npm install cross-env -D
or
require('ts-node').register({dir: <tsconfig.json>}); // required
require('./main.ts'); // import typescript
https://github.com/0x1af2aec8f957/node-compress/blob/master/wrap.js
Most helpful comment
node --require ts-node/registeris required when I want to use--inspectSo my question is,
how can I use both
--inspectfor debugging with Chrome and--projectfor setting my custom tsconfig.json@blakeembrey can you plz take a look