gpt4 book ai didi

node.js - 强制 Node 在 Windows 上使用 git bash

转载 作者:可可西里 更新时间:2023-11-01 13:31:41 32 4
gpt4 key购买 nike

我有一个 package.json 文件,如下所示:

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

当我运行 npm test 时,出现错误:

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

我猜这是因为 Node 正在使用 Windows cmd.exe。如果我以 bash 作为开头,该命令就可以正常工作。我可以更改 Node 中的某种配置设置,以便它自动使用 bash 吗?

最佳答案

将 NPM 的 script-shell 设置为指向 Git Bash(注意较新的路径):

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

这会告诉 NPM 使用指定的 shell 而不是默认情况下,在 Windows 上是 cmd.exe。参见 https://docs.npmjs.com/misc/config#script-shell .

关于node.js - 强制 Node 在 Windows 上使用 git bash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35462422/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com