Force node use git bash in windows

I have a package.json file that looks like this:

{ "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 the npm test, I get an error:

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

I assume this is because node uses windows cmd.exe . The command works great if I predict it with bash . Is it possible to change some configuration parameter in node so that it automatically uses bash?

+5
source share
1 answer

Yes, you can!

Before starting npm run you should do:

 set comspec=your_bash.exe_folder 

NPM package, check the comspec environment and run it on win32. By default, ComSpec=C:\windows\system32\cmd.exe

For more information, you can see the NPM source code: lifecycle.js (line 219)

 if (process.platform === 'win32') { sh = process.env.comspec || 'cmd' shFlag = '/d /s /c' conf.windowsVerbatimArguments = true } 

By default, you can install the comspec, bash environment using the registry. If you need help, please comment.

+5
source

Source: https://habr.com/ru/post/1243238/


All Articles