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?
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 .
Yes you can!
Before running npm run
you should do:
set comspec=your_bash.exe_folder
The NPM package, check the comspec enviroment, and run it on win32. By default ComSpec=C:\\windows\\system32\\cmd.exe
For more info you can see the source code of NPM: lifecycle.js (Line 219)
if (process.platform === 'win32') { sh = process.env.comspec || 'cmd' shFlag = '/d /s /c' conf.windowsVerbatimArguments = true }
You can set the environment comspec, to your bash by default by using the registry. If you need any help, please comment.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.