打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
亲测解决npmERR!UnexpectedendofJSONinputwhileparsingnear...的方法
userphoto

2023.04.03 河北

关注

今天在创建项目的时候,发现一直创建不成功,安装项目依赖的时候报错: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

注意下面走捷径啦!!!!
直接输入npm install --global cnpm
然后使用cnpm install

执行上面命令后,发现问题解决!!!
最简单解决就是输入 npm install --global cnpm 然后使用 cnpm install 装包
原因分析npm官方服务器在国外,网络受阻性大、而淘宝的cnpm在国内,所以用淘宝的快就ok了

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
npm ERR! Unexpected end of JSON input while parsing near ''...“,''
 npm安装报错 解决npm ERR! Unexpected end of JSON input while parsing near
npm ERR! Unexpected token in JSON at position 0 while parsing near ' 解决办法
ES6 - 环境报错整理(1): Unexpected end of JSON input while parsing near '...es":"7.0.0-alpha.11",'
【vue报错】‘vue-cli-service‘ 不是内部或外部命令,也不是可运行的程序
打开android device monitor提示unexpected error while parsing input:Invalid ui automator hierarchy file
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服