git 使用 grunt 运行 Angular.js 时如何修复错误“请设置环境变量 CHROME_BIN”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18924263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix error "Please set env variable CHROME_BIN" when running Angular.js with grunt
提问by trysis
I am trying to do unit tests with AngularJS. I already have bower and grunt installed, so I should be able to do the tests. However, when I run "grunt test" from the terminal (Git Bash in my case), I get the error "Please set env variable CHROME_BIN." According to this StackOverflow question, I should change karma.conf.js and karma-e2e.conf.js, but I can't change them because other people on the project will have issues.
我正在尝试使用 AngularJS 进行单元测试。我已经安装了 bower 和 grunt,所以我应该能够进行测试。但是,当我从终端(在我的情况下是 Git Bash)运行“grunt test”时,出现错误“请设置环境变量 CHROME_BIN”。根据这个 StackOverflow 问题,我应该更改 karma.conf.js 和 karma-e2e.conf.js,但我无法更改它们,因为项目中的其他人会有问题。
回答by Davin Tryon
You need to set CHROME_BIN
as a new environmental variable. Set the value to the path to chrome.exe
. This value is usually: C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
您需要设置CHROME_BIN
为新的环境变量。将值设置为路径chrome.exe
。这个值通常是:C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
Here are the docsthat describe how to configure each type of OS.
回答by beauXjames
For Windows/Chrome, per the cmd box, this would be (by default)
对于 Windows/Chrome,根据 cmd 框,这将是(默认情况下)
C:\SET CHROME_BIN=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
回答by beauXjames
The browser binary path varies by OS.
浏览器二进制路径因操作系统而异。
Changing the path to the Chrome binary:
更改 Chrome 二进制文件的路径:
$ export CHROME_BIN=/usr/local/bin/my-chrome-build
Changing the path to the Chrome Canary binary:
更改 Chrome Canary 二进制文件的路径:
$ export CHROME_CANARY_BIN=/usr/local/bin/my-chrome-build
Changing the path to the PhantomJs binary:
更改 PhantomJs 二进制文件的路径:
$ export PHANTOMJS_BIN=$HOME/local/bin/phantomjs