admin管理员组文章数量:1394139
I have npm scripts in the package.json
, I would like to provide custom parameter from the mand line. I found many stackoverflow questions and answers but none of them works. I tried this solution:
"scripts": {
"foo": "echo $npm_config_foo && echo done"
},
When I run the mand:
$ npm run foo --foo=test
> echo $npm_config_foo && echo done
$npm_config_foo
done
As you can see, it does not echo test
.
This is my configuration:
- OS: Windows
- Terminal: GitBash
- npm version: 7.14.0
I tried this, on Linux and it works. This is related to Windows.
I have npm scripts in the package.json
, I would like to provide custom parameter from the mand line. I found many stackoverflow questions and answers but none of them works. I tried this solution:
"scripts": {
"foo": "echo $npm_config_foo && echo done"
},
When I run the mand:
$ npm run foo --foo=test
> echo $npm_config_foo && echo done
$npm_config_foo
done
As you can see, it does not echo test
.
This is my configuration:
- OS: Windows
- Terminal: GitBash
- npm version: 7.14.0
I tried this, on Linux and it works. This is related to Windows.
Share Improve this question edited May 24, 2021 at 21:03 PierBJX asked May 21, 2021 at 13:02 PierBJXPierBJX 2,3735 gold badges25 silver badges58 bronze badges2 Answers
Reset to default 5The accepted answer is Great but does not work if the Repo is used by both Windows and Linux Users. If so than I remend to use cross-var (https://www.npmjs./package/cross-var)
Just add it into the beginning of the script (after you added it to your dependencies)
"scripts": {
"foo": "cross-var echo $npm_config_foo && echo done",
},
The solution is to use % instead of $.
"scripts": {
"foo": "echo %npm_config_foo% && echo done",
},
本文标签: javascriptProvide custom parameters (npmconfig) to npm scripts on WindowsStack Overflow
版权声明:本文标题:javascript - Provide custom parameters ($npm_config_) to npm scripts on Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744576437a2613653.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论