Daniel
Daniel

Reputation: 15393

@react-native-community/react-native-device-info: NativeModule.RNDeviceInfo is null

I recently conducted a react-native initand when I ranreact-native run-ios` I got this error:

enter image description here

Now your first response will be to say that I must have installed it and not linked it...not so, here is my package.json file:

{
  "name": "NFIBEngage",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "16.8.6",
    "react-native": "0.60.4"
  },
  "devDependencies": {
    "@babel/core": "7.5.5",
    "@babel/runtime": "7.5.5",
    "@react-native-community/eslint-config": "0.0.5",
    "babel-jest": "24.8.0",
    "eslint": "6.1.0",
    "jest": "24.8.0",
    "metro-react-native-babel-preset": "0.55.0",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

boilerplate

So I thought okay, so let me try react-native link react-native-device-info and sure enough I get this error message:

error Unknown dependency. Make sure that the package you are trying to link is already installed in your "node_modules" and present in your "package.json" dependencies. Run CLI with --verbose flag for more details.

Which makes sense since I never installed it in the first place so why would it be in my node modules.

Anyone have any idea what is going on in the world of @react-native-community that I am getting this error with a boilerplate application?

Upvotes: 2

Views: 5245

Answers (2)

Daniel
Daniel

Reputation: 15393

When working on multiple React Native projects, ensure that Metro Bundler is shut down before switching to another project.

The bundler from the other project was still running, and the native app for the new project is loading the bundle from there. Usually you can see an error that says that the port 8081 was already in use, but I must have totally missed that error.

Upvotes: 5

Rishav Kumar
Rishav Kumar

Reputation: 5450

You might have to search for the library react-native-device-info and perform the installation and linking steps for that library.

May be you might have installed some other third party libraries which use that particular library. It's simple with some automatic linking procedures. Just go and add that library through npm or yarn whatever you prefer and then link them by using react native link. (Also try manual linking once if this is repeated). Hope this might resolve this issue.

Upvotes: 1

Related Questions