强制节点在Windows上使用git bash [英] Force node to use git bash on windows
问题描述
我有一个package.json文件,看起来像:
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"
}
}
运行npm测试时,出现错误:
When I run npm test, I get an error:
'.' is not recognized as an internal or external command
我猜这是因为节点正在使用Windows cmd.exe
.如果我以 bash
开头,则该命令可以正常工作.我可以在节点中更改某种配置设置,以使其自动使用bash吗?
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?
推荐答案
设置NPM的 script-shell
指向Git Bash(请注意较新的路径):
Set NPM's script-shell
to point to Git Bash (note the newer path):
npm配置设置脚本外壳"C:\\ Program Files \\ Git \\ bin \\ bash.exe"
这告诉NPM使用指定的外壳程序而不是指定的外壳程序运行在 package.json
中定义的脚本(例如 start
或 test
).默认值,在Windows上为 cmd.exe
.参见 https://docs.npmjs.com/misc/config#script-shell.
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.
这篇关于强制节点在Windows上使用git bash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!