How to fix error “Please set env variable CHROME_BIN” when running Angular.js with grunt

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.

  • ngDrive not defined?
  • Bump a specific version number on SVN using Grunt
  • possible to change where github pages looks for index.html?
  • NPM start throwing errors
  • how to run npm/grunt command from jenkins
  • Angular Constant Best Practice
  • Git on Windows: Where are my files?
  • What are the consequences of using receive.denyCurrentBranch in Git?
  • How to work with submodules and n-tiers git repository strategies
  • GIT: How to checkout a file from a previous commit without overwriting the current one?
  • how to restart a git repository
  • git diff showing only commits that revision/branch A is ahead of revision/branch B
  • 3 Solutions collect form web for “How to fix error “Please set env variable CHROME_BIN” when running Angular.js with grunt”

    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

    Here are the docs that describe how to configure each type of OS.

    https://github.com/karma-runner/karma/blob/master/docs/config/03-browsers.md#correct-path-to-browser-binary

    For Windows/Chrome, per the cmd box, this would be (by default)

    C:\SET CHROME_BIN=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
    

    The browser binary path varies by OS.

    Changing the path to the Chrome binary:

    $ export CHROME_BIN=/usr/local/bin/my-chrome-build
    

    Changing the path to the Chrome Canary binary:

    $ export CHROME_CANARY_BIN=/usr/local/bin/my-chrome-build
    

    Changing the path to the PhantomJs binary:

    $ export PHANTOMJS_BIN=$HOME/local/bin/phantomjs
    
    Git Baby is a git and github fan, let's start git clone.