npm install出现: Unexpected end of JSON input while parsing near

 
 
 1 最近脑子热了一下把Nodejs更新到最新版,来新的项目npm install出现了这个错误。查了一下应该时因为最新版的Nodejs与npm版本不合适的问题(因为没更新Node之前是不会的)。解决办法就是把npm的版本降到4版。
 2 
 3 在windows下使用cmd执行语句:npm -g i npm@4
 4 
 5 Mac系统的就按照相同的思路修改就行啦,btw,在查找的过程中还看到有另外一种解决方法是
 6 
 7 在cmd下(windows)执行:npm cache clean --force
 8 
 9 但是这种方法可能不是针对Nodejs版本太高导致npm版本不合适的问题所以不适用于我的情况。
10 
11 综上,这就是关于Unexpected end of JSON input while parsing near问题常见的两种解决方法啦,希望能帮助到你吧。
 
  
 
1 清除缓存:npm cache clean --force
2.npm 显示配置列表 npm config list
3.淘宝镜像的安装:npm config set registry " https://registry.npm.taobao.org " npm config set disturl https://npm.taobao.org/dist
4.淘宝镜像的卸载:npm config set disturl https://npm.taobao.org/dist

猜你喜欢

转载自www.cnblogs.com/yangguoe/p/9158361.html