我正在使用一个特定的任务运行器来执行名为 Yoshi 的节点脚本。我想从package.json
运行脚本,例如,yoshi test
但使用自定义环境变量(例如special_variable(:
"scripts": {
"start": "yoshi start",
"test": "special_variable=value yoshi test // this case"
}
显然,我可以在我的npm-script
中使用ENV
前缀传递一个环境变量,如下所示:
"scripts": {
"start": "yoshi start",
"test": "ENV special_variable=value yoshi test"
}
我认为您可以创建.env
文件并在那里添加变量。