[英]How to pass an argument in command line to run the script for yarn
i'm pretty new to JS.我对 JS 很陌生。 I know that npm
allows you to use process.env.npm_config_key
to pass variable in command line like我知道npm
允许您使用process.env.npm_config_key
在命令行中传递变量,例如
npm run --key="My Secret Passphrase" test:integration
But how i can do that using yarn
?但我怎么能用yarn
做到这一点?
expected smth like this: yarn run --key="My Secret Passphrase" test:integration
期望像这样: yarn run --key="My Secret Passphrase" test:integration
You could use standard environment variables:您可以使用标准环境变量:
On the command line,在命令行上,
MY_KEY="My Secret Passphrase" yarn run test:integration
And in code, read process.env.MY_KEY
在代码中,阅读process.env.MY_KEY
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.