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

Ubuntu系统下npm安装bootstrap添加到package.json失败如何解决

问题根因

你遇到的Unexpected end of JSON input报错属于npm本地缓存损坏类问题,之前拉取的bootstrap包元数据缓存文件不完整,JSON解析失败导致安装终止。

修复步骤
  • 强制清空npm本地缓存
npm cache clean --force
  • 验证缓存清理结果(非必须,可跳过)
npm cache verify
  • 重新执行bootstrap安装命令
npm install bootstrap --save
  • 若上述操作后仍出现同类错误,可升级npm到最新稳定版后重试
npm install -g npm@latest
可选优化(针对源访问不稳定的情况)

如果是网络波动导致的缓存损坏,可临时指定国内镜像源执行安装:

npm install bootstrap --save --registry=https://registry.npmmirror.com

如果需要长期切换npm源为国内镜像,执行以下命令:

npm config set registry https://registry.npmmirror.com

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.18 11:45:08