You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法从GitHub添加Cordova插件问题求助

Cordova安装GitHub插件失败的解决方法

问题场景

执行以下命令安装Cordova蓝牙打印机插件:

cordova plugin add https://github.com/marcelo-michels/Cordova-Plugin-Bluetooth-Printer.git

错误输出

D:\Cordova\pos>cordova plugin add https://github.com/marcelo-michels/Cordova-Plugin-Bluetooth-Printer.git
Failed to fetch plugin https://github.com/marcelo-michels/Cordova-Plugin-Bluetooth-Printer.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://github.com/marcelo-michels/Cordova-Plugin-Bluetooth-Printer.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\willi\AppData\Roaming\npm-cache\_logs\2023-06-16T03_44_04_148Z-debug.log

错误原因

报错核心是npm ERR! enoent spawn git ENOENT,说明npm尝试调用git命令时找不到程序,原因是:

  • 本地未安装Git
  • Git已安装但未添加到系统环境变量中

解决步骤

  • 检查Git安装状态:打开命令提示符/终端,输入git --version,若提示“git不是内部或外部命令”,则需前往Git官方网站下载对应系统版本完成安装。
  • 配置Git环境变量:
    • 安装Git时务必勾选“Add Git to PATH”选项(默认安装会自动配置,手动安装遗漏则需手动添加)。
    • 手动添加:找到Git安装目录下的bin文件夹(示例路径:C:\Program Files\Git\bin),将该路径添加到系统环境变量的Path列表中。
    • 重启命令提示符/终端,再次执行git --version,确认能正常输出Git版本号。
  • 重新执行插件安装命令:回到Cordova项目目录,再次运行cordova plugin add https://github.com/marcelo-michels/Cordova-Plugin-Bluetooth-Printer.git。

内容的提问来源于stack exchange,提问作者williambernadi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 04:07:05