首页 > Web开发 > 详细

解决npm ERR! Unexpected end of JSON input while parsing near...的方法

时间:2020-12-18 11:51:12      阅读:20      评论:0      收藏:0      [点我收藏+]

解决npm ERR! Unexpected end of JSON input while parsing near...的方法

今天在创建项目的时候,发现一直创建不成功,安装项目依赖的时候报错:npm ERR! Unexpected end of JSON input while parsing near…

具体报错详情:
技术分享图片经过自己亲测发现如下解决方法:
方案一(亲测已解决):

  1. 清除缓存
npm cache clean --force
  1. 再安装
npm install

方案二(亲测):
第一次按照上面的方法 npm cache clean --force 轻松就解决问题了,但是今天我用的时候发现依然报错:

npm ERR! Unexpected end of JSON input while parsing near...
......
npm ERR! A complete log of this run can be found in:
......

于是我就按着上次的方法发现不行,还是报错,我就又连着试了好几次还是不行
后来查阅各种方案,发现只需要把镜像改一下就行了,具体看下面

  1. 第一步还是:npm cache clean --force
npm cache clean --force
  1. 第二步:切换为淘宝镜像
npm config set registry https://registry.npm.taobao.org/
npm config get registry https://registry.npm.taobao.org/

验证时候切换淘宝镜像成功,命令行输入: npm config list
技术分享图片

3.第三步:

npm install

本文引自

https://blog.csdn.net/zsl15039718107/article/details/104128166/

解决npm ERR! Unexpected end of JSON input while parsing near...的方法

原文:https://www.cnblogs.com/coderD/p/14153730.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!