![](/img/trans.png)
[英]ts-node programmatic usage with require('ts-node/register')
[英]ts-node pass options to node
有沒有辦法在調用 ts-node 時將選項傳遞給 node? 我正在嘗試在 node 中使用一個實驗性功能,如果它可以與 ts-node 一起使用,它會膨脹。
這就是我目前正在做的事情:
ts-node ./src/utils/repl.ts -- --experimental-repl-await
我讓它以這種方式工作:
node --experimental-repl-await -r ts-node/register ./src/utils/repl.ts
注意:如果您需要使用高級 node.js CLI 參數(例如
--inspect
),請將它們與node -r ts-node/register
而不是ts-node
CLI。
另一種方法是使用NODE_OPTIONS
環境變量。 例如,在 *nix 風格的 shell 中:
NODE_OPTIONS=--experimental-repl-await ts-node ./src/utils/repl.ts
與Node.js本身一樣,選項位於腳本之前 。 (腳本之后的選項是腳本的選項,而不是Node.js。)
ts-node --experimental-repl-await ./src/utils/repl.ts --
從文檔中 :
您可以通過在腳本路徑之前傳遞它們,通過編程用法或通過環境變量來設置選項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.