0
点赞
收藏
分享

微信扫一扫

umi3.5新特性 mfsu报错 Unexpected token in JSON at position 0, try to remove cache file and retry.

Brose 2022-01-20 阅读 24

项目场景:

最近在开发react项目,在npm start启动项目的时候,突然报了一堆错误。最后发现是,umi3.5的新特性 mfsu导致的。


问题描述:

⏱️  MFSU Enabled
Unexpected token   in JSON at position 0, try to remove cache file and retry.
Error: Unexpected token   in JSON at position 0, try to remove cache file and retry.
    at DepInfo.loadCache (D:\前端学习\AntDesignPro\grafana-react\node_modules\umi\node_modules\@umijs\preset-built-in\lib\plugins\features\mfsu\DepInfo.js:129:13)
    at Object.<anonymous> (D:\前端学习\AntDesignPro\grafana-react\node_modules\umi\node_modules\@umijs\preset-built-in\lib\plugins\features\mfsu\mfsu.js:229:15)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (D:\前端学习\AntDesignPro\grafana-react\node_modules\umi\node_modules\@umijs\preset-built-in\lib\plugins\features\mfsu\mfsu.js:113:103)
    at _next (D:\前端学习\AntDesignPro\grafana-react\node_modules\umi\node_modules\@umijs\preset-built-in\lib\plugins\features\mfsu\mfsu.js:115:194)
    at D:\前端学习\AntDesignPro\grafana-react\node_modules\umi\node_modules\@umijs\preset-built-in\lib\plugins\features\mfsu\mfsu.js:115:364
    at new Promise (<anonymous>)
    at Object.<anonymous> (D:\前端学习\AntDesignPro\grafana-react\node_modules\umi\node_modules\@umijs\preset-built-in\lib\plugins\features\mfsu\mfsu.js:115:97)
    at Object.fn (D:\前端学习\AntDesignPro\grafana-react\node_modules\umi\node_modules\@umijs\preset-built-in\lib\plugins\features\mfsu\mfsu.js:238:19)
    at D:\前端学习\AntDesignPro\grafana-react\node_modules\@umijs\core\lib\Service\Service.js:623:28

在这里插入图片描述


解决方案:

在config.ts中可以找到mfsu:{}选项,umi3.5的新特性,让热更新更加快速。在大佬的帮助下,总结了几种解决方案。

  1. 直接注释掉mfsu:{},取消mfsu特性。【不推荐】
    在这里插入图片描述
    缺点就是,热更新变慢,而且因为是umi新版本,所以会在你打包的时候提示你热更新有点慢。
    在这里插入图片描述
  2. 删除掉src目录下的.umi文件夹,再重新进行npm start。应该是umi里面存缓文件的问题,删除后再重新打包,会重新启动MFSU。【推荐】
    在这里插入图片描述
举报

相关推荐

0 条评论