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

执行npm install firebase安装依赖时出现FETCH_ERROR错误如何解决?

报错说明

npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/@firebase%2ffirestore reason: Unexpected end of JSON input

执行命令:npm install --save firebase

解决方案
  • 清理npm损坏的本地缓存
    执行命令:npm cache clean --force
    该报错绝大多数情况是之前拉取包时缓存的JSON元数据文件损坏导致,强制清理缓存后即可正常拉取。
  • 替换npm镜像源解决网络访问问题
    若访问npm官方源不稳定,可临时指定国内镜像执行安装:
    npm install --save firebase --registry=https://registry.npmmirror.com
    如需长期修改默认镜像源,执行:
    npm config set registry https://registry.npmmirror.com
  • 清理项目内的残留安装文件
    若执行以上操作后仍然报错,删除项目目录下的node_modules文件夹和package-lock.json文件后重新执行安装命令即可。
  • 检查网络配置
    确认当前网络没有代理冲突,如有开启全局代理可先关闭后再尝试安装。

内容的提问来源于stack exchange,提问作者adam dwi maulana

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.04 22:48:03