You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native V63+报错:TurboModuleRegistry及LinkingManager不变违规

Fixing Two Invariant Violation Errors with TurboModuleRegistry in React Native 0.63+

Hey there, I've run into both of these exact issues while working with React Native 0.63+ projects, so I can share some tried-and-true solutions that worked for me and other devs:

First: General Fixes for Invariant Violation: TurboModuleRegistry.getEnforcing(...)

This error usually pops up because React Native 0.63+ enables TurboModules (part of the New Architecture) by default, and either your native modules aren't registered properly or a dependency hasn't adapted to this change.

  • Disable TurboModules temporarily (quick fix if you're not ready for the New Architecture):

    • For iOS: Update your Podfile with these settings, then run pod install:
      use_react_native!(
        :path => config[:reactNativePath],
        :fabric_enabled => false,
        :new_arch_enabled => false
      )
      
    • For Android: Add this line to android/gradle.properties:
      newArchEnabled=false
      
      Clean your project and rebuild afterward.
  • Check third-party dependencies: If the error traces back to a specific library, check its docs to see if it supports TurboModules for RN 0.63+. If not, upgrade to the latest version, switch to an alternative library, or temporarily roll back to a compatible RN version.

  • Re-link native modules: Even though RN 0.60+ uses auto-linking, sometimes a manual link fixes glitches. Run:

    npx react-native link
    

    Then rebuild your project.

Second: Fixing Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'LinkingManager' not found

This specific error is tied to the Linking module, which got some changes in RN 0.63+. Here's how to fix it:

  • Verify your Linking import: Make sure you're using the official, up-to-date import instead of the old LinkingManager:

    import { Linking } from 'react-native';
    

    LinkingManager is deprecated and has been rolled into the main Linking module.

  • Reinstall react-native core: Corrupted core files can cause this issue. Run these commands:

    npm uninstall react-native
    npm install react-native@your-current-rn-version
    

    Rebuild both iOS and Android projects after this.

  • Manual Link for iOS: If auto-linking failed, add the Linking module manually in Xcode:

    1. Open your project's .xcworkspace file
    2. Right-click the Libraries folder and select Add Files to "[Your Project Name]"
    3. Navigate to node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj and add it
    4. Go to Build Phases > Link Binary With Libraries and add libRCTLinking.a
  • Check Android configuration: In android/app/src/main/java/[your-package]/MainApplication.java, ensure LinkingPackage is included in your packages list:

    import com.facebook.react.modules.linking.LinkingPackage;
    
    @Override
    protected List<ReactPackage> getPackages() {
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Add this if it's missing from the auto-generated list
      packages.add(new LinkingPackage());
      return packages;
    }
    

    Clean the project and rebuild once done.


内容的提问来源于stack exchange,提问作者Rajesh N

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 14:27:35