Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ts-node pass options to node

Is there a way to pass options to node when invoking ts-node? I am trying to use an experimental feature in node and it would be swell if it would work with ts-node.

This is currently what I am doing:

ts-node ./src/utils/repl.ts -- --experimental-repl-await
like image 643
unflores Avatar asked Feb 14 '19 17:02

unflores


1 Answers

I got it to work this way:

node --experimental-repl-await -r ts-node/register ./src/utils/repl.ts

From the ts-node documentation:

Note: If you need to use advanced node.js CLI arguments (e.g. --inspect), use them with node -r ts-node/register instead of the ts-node CLI.


Another way to do it is to use the NODE_OPTIONS environment variable. For instance, in a *nix-style shell:

NODE_OPTIONS=--experimental-repl-await ts-node ./src/utils/repl.ts
like image 120
Sam Avatar answered Sep 18 '22 15:09

Sam