0

I'm trying to use the --exec option to run a command before the nestjs server start (--require). I want to modify the start:dev script in my package.json

But I can not make it work, always got an error

this command line works fine :

npx ts-node --require ./src/common/telemetry/telemetry.ts ./src/main.ts 

I tried these couple of syntax in package.json

 "start:dev": "nest start --watch --exec \"ts-node --require ./src/common/telemetry/telemetry.ts\"", "start:dev": "nest start --watch --exec ts-node --require ./src/common/telemetry/telemetry.ts", 

but both failed with ARG_UNKOWN_OPTION error (see details below).

Thks for your help

Error: Unknown or unexpected option: --enable-source-maps at arg (C:\Users\jerom\dev\stelogy\apiLeoniJira\node_modules\arg\index.js:88:19) at parseArgv (C:\Users\jerom\dev\stelogy\apiLeoniJira\node_modules\ts-node\dist\bin.js:69:12) at main (C:\Users\jerom\dev\stelogy\apiLeoniJira\node_modules\ts-node\dist\bin.js:25:18) at Object.<anonymous> (C:\Users\jerom\dev\stelogy\apiLeoniJira\node_modules\ts-node\dist\bin.js:579:5) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Module._extensions..js (node:internal/modules/cjs/loader:1691:10) at Module.load (node:internal/modules/cjs/loader:1317:32) at Module._load (node:internal/modules/cjs/loader:1127:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) { code: 'ARG_UNKNOWN_OPTION' } 
2
  • which nodejs version are you using? Commented Oct 29, 2024 at 15:36
  • @MicaelLevi V22.9 Commented Oct 29, 2024 at 16:06

1 Answer 1

1

that --enable-source-maps flag is injected by NestJS's CLI for NodeJS. As you're using ts-node instead of node, it won't work because ts-node does not support --enable-source-maps (see https://github.com/TypeStrong/ts-node/issues/807)

As per https://github.com/nestjs/nest-cli/issues/2678#issuecomment-2268336322 you can probably use ts-node alone instead of via NestJS's CLI.

Sign up to request clarification or add additional context in comments.

1 Comment

got it, will go this way

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.