naderabdalghani
naderabdalghani

Reputation: 1189

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually

This error came up after upgrading to React Native 0.60.

I've tried to manually unlink each manually linked dependency using react-native unlink <dependency> as suggested in the error message, but the problem still persists.

The error message is as follows:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - react-native-admob (to unlink run: "react-native unlink react-native-admob")
  - react-native-facebook-account-kit (to unlink run: "react-native unlink react-native-facebook-account-kit")
  - react-native-fbsdk (to unlink run: "react-native unlink react-native-fbsdk")
  - react-native-gesture-handler (to unlink run: "react-native unlink react-native-gesture-handler")
  - react-native-linear-gradient (to unlink run: "react-native unlink react-native-linear-gradient")
  - react-native-localization (to unlink run: "react-native unlink react-native-localization")
  - react-native-restart (to unlink run: "react-native unlink react-native-restart")
  - react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons")
  - react-native-webview (to unlink run: "react-native unlink react-native-webview")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md

Upvotes: 25

Views: 78501

Answers (7)

Edu Programer
Edu Programer

Reputation: 31

just typing this: working for me

  1. npx react-native unlink react-native-vector-icons
  2. npm remove node_module
  3. yarn cache clean
  4. yarn install
  5. watchman watch-del-all
  6. rm -fr $TMPDIR/metro-cache
  7. yarn start --clear

Upvotes: 3

Samuel
Samuel

Reputation: 111

I got this error "React Native CLI uses auto linking for native dependencies, but the following modules are linked manually". I then solve the error by removing those three dependencies, react-native-gesture-handler, react-native-reanimated and react-native-vector-icons from my IOS project with these three commands;

react-native unlink react-native-gesture-handler --platforms ios
react-native unlink react-native-reanimated --platforms ios
react-native unlink react-native-vector-icons --platforms ios

and then, $ cd ios and then ios/myproject$ pod install and then cd ..and then myproject$ npx react-native run-ios

Upvotes: 11

Bill Dai
Bill Dai

Reputation: 1

I don't see any perfect answers above. Those are workarounds that do not really address the root cause of the issue.

This issue bugged me a couple of months until I spent a day looking into this today. The issue is caused by two things:

1. Gradle Files are out of sync in Android Studio.

Open Android Studio and select the android directory from your React Native project and the Android Studio will auto-sync and build the project. If not, manually select File->Sync Pojrect with Gradle Files. And 9 out 10 times it will run into issues. Either caused by an out of date package still using "compile" instead of "implementation" or some other weird kotlin related issues. You can try these steps

a) Update the package to a newer version or manually replace all lines start with compile to implementation.

b) File->Invalidate Caches /Restart and then select Invalidate and Restart.

c) Build->Clean Project

If none of these above, then Google up each individual issue, and make sure the project syncs and builds successfully.

Now you can try running react-native run-android and see if the unlinking error message still shows. If still persists, do the following.

2. modules are still loaded

In Android studio, you will see a .idea directory. Remove the modules.xml (backup first just in case) file under the /.idea. And then do sync and build again.

This should resolve the auto-linking error message.

Upvotes: 0

Play Ra
Play Ra

Reputation: 17

react-native-config.js

module.exports = {
  dependencies: {
    'react-native.config': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
};

Upvotes: -1

user8572385
user8572385

Reputation: 615

The following worked for me removing node_modules from your project then running npm install to reinstall all the modules.

Upvotes: 0

Shriram Navaratnalingam
Shriram Navaratnalingam

Reputation: 3187

Basically Autolinking is a replacement for react-native link. If you have been using React Native before version 0.60.

But you can also disable autolinking for unsupported library

During the transition period some packages may not support autolinking on certain platforms. To disable autolinking for a package, update your react-native.config.js's dependencies entry to look like this:

// react-native.config.js

module.exports = {
  dependencies: {
    'some-unsupported-package': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
};

For further clarification follow this link : https://github.com/react-native-community/cli/blob/master/docs/autolinking.md

Upvotes: 10

naderabdalghani
naderabdalghani

Reputation: 1189

I managed to make the error go away by doing as follows:

  1. Create a react-native.config.js file in the root of your project.
  2. Update it to something like this:
// react-native.config.js
module.exports = {
  dependencies: {
    '<dependency>': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink
      },
    },
  },
};

Source

Upvotes: 13

Related Questions