[英]ts-node pass options to node
Is there a way to pass options to node when invoking ts-node?有没有办法在调用 ts-node 时将选项传递给 node? I am trying to use an experimental feature in node and it would be swell if it would work with ts-node.我正在尝试在 node 中使用一个实验性功能,如果它可以与 ts-node 一起使用,它会膨胀。
This is currently what I am doing:这就是我目前正在做的事情:
ts-node ./src/utils/repl.ts -- --experimental-repl-await
I got it to work this way:我让它以这种方式工作:
node --experimental-repl-await -r ts-node/register ./src/utils/repl.ts
From the ts-node
documentation :从ts-node
文档:
Note: If you need to use advanced node.js CLI arguments (eg
--inspect
), use them withnode -r ts-node/register
instead of thets-node
CLI.注意:如果您需要使用高级 node.js CLI 参数(例如--inspect
),请将它们与node -r ts-node/register
而不是ts-node
CLI。
Another way to do it is to use the NODE_OPTIONS
environment variable.另一种方法是使用NODE_OPTIONS
环境变量。 For instance, in a *nix-style shell:例如,在 *nix 风格的 shell 中:
NODE_OPTIONS=--experimental-repl-await ts-node ./src/utils/repl.ts
Just as with Node.js itself, options go before the script. 与Node.js本身一样,选项位于脚本之前 。 (Options after the script are options to the script, not Node.js.) (脚本之后的选项是脚本的选项,而不是Node.js。)
ts-node --experimental-repl-await ./src/utils/repl.ts --
From the documentation : 从文档中 :
You can set options by passing them before the script path, via programmatic usage or via environment variables. 您可以通过在脚本路径之前传递它们,通过编程用法或通过环境变量来设置选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.