pass arguments as module's argument on nodejs

56 views Asked by At

well, here's my script node --loader ts-node/esm --no-warnings=ExperimentalWarning index.ts. I want to pass --transpile-only argument to ts-node. but, didn't find any useful doc/solution. how do I achieve this?

1

There are 1 answers

1
Md Nazmul Hossain On

To pass the --transpile-only argument to ts-node when using it as a loader with Node.js, you can adjust the command by setting the TS_NODE_TRANSPILE_ONLY environment variable. This environment variable can be used to enable the transpile-only mode for ts-node, which skips type checking for faster execution.

Use the TS_NODE_TRANSPILE_ONLY=1 environment variable setting before your command. This sets the variable for the duration of the command:

TS_NODE_TRANSPILE_ONLY=1 node --loader ts-node/esm --no-warnings index.ts

By setting the TS_NODE_TRANSPILE_ONLY environment variable to 1, you instruct ts-node to operate in transpile-only mode, which can lead to faster execution times by skipping type checks. This approach is useful for development environments where you prioritize speed over complete type safety.