问题
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
回答1:
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 withnode -r ts-node/register
instead of thets-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
来源:https://stackoverflow.com/questions/54695736/ts-node-pass-options-to-node