[英]How do I use --node-arg in npx / npm version 7?
npx
曾經有一個--node-arg
選項來指定節點的選項。 在 npm v7 中,這會導致:
npx: the --n argument has been removed.
See `npm help exec` for more information
其中指出:
The --node-arg and -n options are removed.
沒有提供有關其更換的任何信息。 這沒有幫助。
我試過使用--
。 例如,使用-r
節點選項運行npx jest -t 'API work'
:
npx -r dotenv/config dotenv_config_path=/home/mike/Code/myapp/.env.local -- jest -t 'API works'
然而,這並沒有做任何事情。
我只是想在評論中喊出 RobC 的答案,因為它確實對我有用。 --node-args
已被--node-options
取代。 例如,使用 Fastify 和 Typescript:
// package.json
"scripts": {
...
"dev": "npx --node-options='-r dotenv/config' tsnd --respawn src/index.ts",
...
},
如果您在package.json
中使用它,請確保將所有命令放在單引號( ''
) 中!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.