“bash”未被识别为内部或外部命令

21

我在安装react-flux-starter-kit-windows时遇到了错误。 我已经安装了最新的node.js和npm。 当我使用以下命令时: npm install -g react-flux-starter-kit 它会给我返回以下错误信息:

react-flux-starter-kit@1.1.4 postinstall C:\Users\Hardik\AppData\Roaming\npm\node_modules\react-flux-starter-kit
bash setup.sh
'bash' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\Hardik\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "-g" "react-flux-starter-kit"
npm ERR! node v6.9.5
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! react-flux-starter-kit@1.1.4 postinstall: bash setup.sh
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-flux-starter-kit@1.1.4 postinstall script 'bash setup.sh'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-flux-starter-kit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bash setup.sh
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs react-flux-starter-kit
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls react-flux-starter-kit
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Hardik\AppData\Roaming\npm-cache_logs\2017-02-22T10_01_48_356Z-debug.log
6个回答

13

4

如果 path 环境变量中没有安装 bash,则会出现相同的错误,因此您需要手动添加它。 将此目录添加到您的 path 环境变量中: C:\Program Files\Git\bin


3

跟随以下步骤:

设置->更新->针对开发人员->开发人员模式->打开->确认。 控制面板->程序和功能->启用或关闭Windows功能->Linux子系统->重启电脑。


这很有帮助,但我仍然无法完全解决问题。之后我不得不安装Ubuntu应用程序。 - Nasim B. D

2

要在Windows上解决这个问题,如果你安装了git for windows,你会在以下目录找到git.exe

C:\Program Files\Git\cmd

但是文件是 git.exe,而你需要 Windows 的 bash.exe

因此,使用这个方法创建一个 doskey 别名来调用 bash 命令。

doskey bash=git

现在在命令行中输入bash,您应该能够看到来自git.exe的帮助输出。

1
我遇到了同样的问题,并分两个步骤解决了它: 首先,我打开了“开发人员模式”(设置 -> 更新和安全 -> 适用于开发人员)。 其次,我从Microsoft Store安装了Ubuntu应用程序,然后以管理员身份运行了命令提示符,输入了bash并设置了用户名和密码。

0
如果您使用的是Windows操作系统,那么您可以使用GIT Bash。您可能已经安装了它,或者可以从https://gitforwindows.org/获取它,而不是使用Windows命令提示符或Windows PowerShell。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接