Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force node to use git bash on windows

I have a package.json file that looks like:

{
  "name": "APP",
  "version": "3.0.0",
  "private": true,
  "scripts": {
    "start": "node app.js",
    "test": "./test/dbLoad && env db=test test=1 jasmine"
  }
}

When I run npm test, I get an error:

'.' is not recognized as an internal or external command

I'm guessing this is because node is using windows cmd.exe. The command works fine if i preface it with bash. Can I change a configuration setting of some kind in node so that it automatically uses bash?

like image 347
Rob Allsopp Avatar asked Feb 17 '16 16:02

Rob Allsopp


1 Answers

Set NPM's script-shell to point to Git Bash (note the newer path):

npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"

This tells NPM to run scripts defined in your package.json (such as start or test) using the specified shell instead of the default, which on Windows is cmd.exe. See https://docs.npmjs.com/misc/config#script-shell.

like image 197
jfroy Avatar answered Sep 22 '22 05:09

jfroy