[英]Provide custom parameters ($npm_config_) to npm scripts on Windows
I have npm scripts in the package.json
, I would like to provide custom parameter from the command line.我在 package.json 中有
package.json
脚本,我想从命令行提供自定义参数。 I found many stackoverflow questions and answers but none of them works.我发现了许多 stackoverflow 问题和答案,但没有一个有效。 I tried this solution:
我试过这个解决方案:
"scripts": {
"foo": "echo $npm_config_foo && echo done"
},
When I run the command:当我运行命令时:
$ npm run foo --foo=test
> echo $npm_config_foo && echo done
$npm_config_foo
done
As you can see, it does not echo test
.如您所见,它不会回显
test
。
This is my configuration:这是我的配置:
- OS: Windows
- Terminal: GitBash
- npm version: 7.14.0
I tried this, on Linux and it works.我在 Linux 上试过这个,它可以工作。 This is related to Windows.
这与 Windows 有关。
The solution is to use % instead of $.解决方案是使用 % 而不是 $。
"scripts": {
"foo": "echo %npm_config_foo% && echo done",
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.