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

React Native自动链接版本下unlink失效问题求助

Fixing "Manually Linked Modules" Error in React Native >0.59

Hey there, I’ve run into this exact issue before—sometimes the react-native unlink command doesn’t fully clean up all traces of manual linking, leaving config files with leftover references that the CLI still picks up. Let’s walk through a step-by-step reset and fix process:

First, make sure you explicitly unlink every module the error mentions. Even if you ran some already, re-running won’t hurt:

react-native unlink @react-native-community/async-storage
react-native unlink react-native-fbsdk
react-native unlink react-native-vector-icons

Step 2: Manually Clean Android Configuration Traces

The auto-unlink often misses entries in Android’s core config files—let’s hunt those down:

  • MainApplication.java: Open android/app/src/main/java/[your-package-name]/MainApplication.java and remove any import statements for the modules (e.g., import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;) plus their corresponding lines in the getPackages() method.
  • settings.gradle: Delete lines like include ':react-native-vector-icons' and project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') for each problematic module.
  • app/build.gradle: Check the dependencies block and remove any lines like implementation project(':react-native-fbsdk').

Step 3: Manually Clean iOS Configuration Traces (If Needed)

If you also build for iOS, repeat similar cleanup steps there:

  • Open your Xcode project, navigate to the Libraries folder, right-click the module folders (e.g., RNVectorIcons.xcodeproj) and select "Move to Trash".
  • Open ios/[your-project-name].xcodeproj/project.pbxproj (make a backup first!), search for the module names, and delete all related entries.
  • If you use CocoaPods, check your Podfile for references to these modules, remove them, then run pod install in the ios directory.

Step 4: Clear Caches and Rebuild

Old cache can hold onto stale references—wipe them out before rebuilding:

# Reset React Native packager cache
npx react-native start --reset-cache

# Clean Android build artifacts
cd android && ./gradlew clean
cd ..

# Re-run the Android build
npx react-native run-android

Step 5: Nuke and Reinstall Dependencies (Last Resort)

If all else fails, a fresh dependency install can resolve hidden conflicts:

rm -rf node_modules package-lock.json yarn.lock
npm install # Or yarn install if you use Yarn

Why This Happens

The react-native unlink command works for most cases, but it can miss manual edits you might’ve made to config files in the past, or fail to fully remove references if there was an interruption during the unlink process. Manual cleanup ensures no leftover code is triggering the CLI’s manual link detection.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:22:14