android - react 原生 : Error "Unexpected identifier ' _classCallCheck'. 导入调用只需要一个参数”

标签 android react-native

在使用 react-native run-android 打开我的项目后,我在我的 android 程序上使用 React-Native ,错误发生了。同样的错误信息出现了两次。

Unexpected identifier '_classCallCheck'.import call expects exactly one argument

Unexpected identifier '_classCallCheck'.import call expects exactly one argument

no stack

no stack
我用谷歌搜索了这个并尝试了一些解决方案,但仍然无法解决。
这是我发现的类似问题:
https://github.com/facebook/react-native/issues/23669
我已经尝试过这个错误:
  • cd 到/andorid,使用 gradlew clean
  • 使用 react-native start --reset-cache
  • 使用 npm install -g react-native-cli

  • 这是我的开发环境:
    Android: 
    AVD version: Android 7.0 with Play Store    
    System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 2.11 GB / 15.71 GB
    Binaries:
    Node: 10.16.0 - D:\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.9.0 - D:\nodejs\npm.CMD
    Watchman: Not Found
    SDKs:
    Android SDK:
      API Levels: 28, 32
      Build Tools: 28.0.3, 32.0.0
      System Images: android-24 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
      Android NDK: Not Found
    Windows SDK: Not Found
    IDEs:
    Android Studio: Version     2020.3.0.0 AI-203.7717.56.2031.7935034
    Visual Studio: Not Found
    Languages:
    Java: 1.8.0_232
    npmPackages:
    @react-native-community/cli: Not Found
    react: 16.9.0 => 16.9.0
    react-native: ^0.64.0 => 0.64.3
    react-native-windows: Not Found
    npmGlobalPackages:
    *react-native*: Not Found
    
    伙计们,我刚刚解决了这个问题。这是链接。
    https://github.com/babel/babel/issues/14139
    从:
    module.exports = {
       presets: ['module:metro-react-native-babel-preset'],
    };
    
    至:
    module.exports = {
       presets: [['module:metro-react-native-babel-preset', {
            unstable_disableES6Transforms: true
        }]],
    };
    

    最佳答案

    我遇到了同样的问题,上面的步骤不起作用,所以我将 metro-react-native-babel-preset 从 0.56.0 更新到 0.59.0 并且它起作用了。

    关于android - react 原生 : Error "Unexpected identifier ' _classCallCheck'. 导入调用只需要一个参数”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70737126/

    相关文章:

    android - getFromLocationName 错误,服务不可用。一直在工作,停止

    android - 无法使用 android JellyBean 启动接收器 : android. os.NetworkOnMainThreadException

    javascript - 设置合适的视口(viewport),与 ios 和 android 兼容,可与旋转配合使用

    android - React-native ERROR : In <declare-styleable> FontFamilyFont, 无法找到属性 android:fontVariationSettings

    ios - iOS:NetInfo.isConnected始终返回false

    javascript - React Native 如何在 Flex 方向行内使用 <br>

    ios - React Native iOS 卡在 LaunchScreen 上

    android - 选择的 Kotlin AutoCompleteTextView 适配器项目提供不同的值

    android - Android 上的短信网址

    android - react native : android emulator won't show up developer menu