named parameter to npm run script

早过忘川 提交于 2019-12-06 15:42:35
robertklep

Just found out that this works:

"scripts":{
  "say-hello" : "echo $npm_config_greeting && ls"
}

Edit:

Any environment variables that start with npm_config_ will be interpreted as a configuration parameter. For example, putting npm_config_foo=bar in your environment will set the foo configuration parameter to bar.

npm docs

Another way is to simply add the following '--' followed by your desired param(s). This would be for named parameters that '=' a value. Please note the underlying process in this example, a protractor call, expects a Url arg.

npm run e2e -- --Url="https://yoururlhere.com"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!