美文网首页
npm ERR! Unexpected end of JSON

npm ERR! Unexpected end of JSON

作者: magic_pill | 来源:发表于2019-08-21 10:50 被阅读0次

create-react-app myApp 时报错以及处理方法:

  • 当使用 create-react-app 脚手架创建项目时,报如下错误:
npm ERR! Unexpected end of JSON input while parsing near '...0tdKmsmvO9uKB\nh09WhK'
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-08-21T01_41_58_040Z-debug.log
Aborting installation.
    npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.

解决方法:

方法一:
  • 在要创建的项目目录下,终端运行: npm cache clean --force
  • 会报一个警报:npm WARN using --force I sure hope you know what you are doing.,提示“你使用的是强制操作,谨慎使用”的意思,不用管它。
方法二:
  • 切换 node 版本,使用高版本 node;
  • 笔者使用 8.14.0 版本,一直报错,然后切换到 10.14.0 版本;
  • 然后再用 方法一 清除缓存之后,创建成功。
方法三:
  • 如果方法一方法二都没有解决你的问题,那就只能使用该方法了;
  • reinstall create-react-app。

注:暂时通过以上几种方法都能解决问题,如果还有其它解决该问题的方法,欢迎留言~

相关文章

网友评论

      本文标题:npm ERR! Unexpected end of JSON

      本文链接:https://www.haomeiwen.com/subject/mcavsctx.html