ts-node pass options to node

ぃ、小莉子 提交于 2021-02-18 22:28:01

问题


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 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


来源:https://stackoverflow.com/questions/54695736/ts-node-pass-options-to-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!