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

Windows10下Node.js与Git冲突致@google/genai安装失败

解决@google/genai安装失败的问题

核心原因

你的环境被错误配置为从不存在的GitHub仓库拉取@google/genai包,而非从官方npm registry获取,导致安装失败。

具体解决步骤

  • 检查并重置npm源配置
    执行以下命令查看是否存在针对@google包的特殊源配置:

    npm config get @google:registry
    npm config get registry
    

    如果@google:registry被设置为Git相关地址,执行命令删除并重置为官方源:

    npm config delete @google:registry
    npm config set registry https://registry.npmjs.org/
    
  • 清除npm缓存
    缓存中的错误地址可能导致问题残留,执行强制清理:

    npm cache clean --force
    
  • 修复Git全局配置冲突
    之前设置的insteadOf规则可能存在重复或错误,先查看现有规则:

    git config --global --get-regexp url.insteadOf
    

    删除多余规则后保留一条正确的:

    git config --global --unset url."https://github.com/".insteadOf
    git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"
    
  • 强制从npm registry安装
    安装时直接指定官方源,绕过可能的配置问题:

    npm install @google/genai --registry=https://registry.npmjs.org/
    
  • 检查系统环境变量
    确保Node.js和Git的安装目录已添加到系统PATH:

    • 打开「系统属性」→「高级」→「环境变量」,检查PATH中是否包含Node.js目录(如C:\Program Files\nodejs\)和Git的bin目录(如C:\Program Files\Git\bin\)
    • 缺失则添加,重启命令行工具后重试安装
  • 临时跳过Git依赖(应急方案)
    若不想保留Git,安装时禁用Git相关操作:

    npm install @google/genai --no-git-tag-version
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 10:52:42