前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >捉虫记:Unexpected end of JSON input while parsing

捉虫记:Unexpected end of JSON input while parsing

作者头像
山月
发布2020-08-17 16:26:54
8910
发布2020-08-17 16:26:54
举报

今天在升级 serverless 时,未能安装成功,提示问题如下

代码语言:javascript
复制
$ npm i -g serverless
npm ERR! Unexpected end of JSON input while parsing near '...oyNMOOPIvOSSv8aveUYxO'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-07-17T09_32_21_882Z-debug.log

捉虫

既然是 npm 的问题,那首先去 github 的源码中找找问题

npm 的源码在 https://github.com/npm/cli,找到以下 Issue

  • Unexpected end of JSON input while parsing near #21172[1]

解决方案

这是因为本地 npm cache 的问题,清除掉本地的 cache 即可成功,如下所示

代码语言:javascript
复制
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.

$ npm i -g serverless

另外可以通过 npm cache verify 去查看缓存位置

代码语言:javascript
复制
$ npm cache verify
Cache verified and compressed (~/.npm/_cacache):
Content verified: 4217 (168362093 bytes)
Index entries: 5814
Finished in 11.194s

Reference

[1]

Unexpected end of JSON input while parsing near #21172: https://github.com/npm/npm/issues/21172

[2]

每日一题: https://github.com/shfshanyue/Daily-Question

[3]

前端面试题小记: https://q.shanyue.tech/fe/

[4]

前端大厂面经大全集: https://q.shanyue.tech/interview.html

[5]

计算机基础面试题小计: https://q.shanyue.tech/base/

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-08-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 全栈成长之路 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 捉虫
  • 解决方案
    • Reference
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档