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-arg
已被--node-options
取代。例如,使用fasttify和Typescript:
// package.json
"scripts": {
...
"dev": "npx --node-options='-r dotenv/config' tsnd --respawn src/index.ts",
...
},
确保所有的命令都用单引号括起来(''
)如果你在package.json
中使用它