首页 > 解决方案 > React native:无法加载捆绑意外的超类

问题描述

每当我运行 IOS 模拟器时,它总是给我这个错误!这是为什么?

error: bundling failed: SyntaxError: .../node_modules/react-native/Libraries/Blob/FileReader.js: Unexpected super class type: CallExpression
  35 | const DONE = 2;
  36 | 
> 37 | class FileReader extends EventTarget(...READER_EVENTS) {
     |                          ^
  38 |   static EMPTY = EMPTY;
  39 |   static LOADING = LOADING;
  40 |   static DONE = DONE;
    at File.buildCodeFrameError

标签: reactjsreact-native

解决方案


之前遇到过这个问题,我已经过时了,安装react-native和升级你的项目,它应该可以工作。react-native-clireact-native-git-upgrade

同时运行以下命令:

watchman watch-del-all &&
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* && 
rm -rf node_modules/ && 
yarn cache clean &&
yarn install && 
yarn start -- --reset-cache

推荐阅读