@React-native-community/react-native-device-info: NativeModule.RNDeviceInfo is null. To fix this issue these steps: *Run 'react-native link
Asked Answered
G

6

8

I just created the app with "react-native init NameProject" and had a Base directory that I use constantly, so when I inserted it, I installed the dependencies and link, it happens to me ... I already deleted the "node_modules" directory, reinstalled, re -linked and nothing seems to solve the problem ...

Screenshot:

enter image description here

Geomorphic answered 2/8, 2019 at 2:45 Comment(1)
Is it trouble in ios??Yucca
L
3

Try running the command

react-native link react-native-device-info

or

cd ios && pod install && cd ..

Then try running your project again using whichever command you used to start your application react-native run-android or react-native run-ios or directly run the app from XCode.

Because starting react-native 0.60.0 or newer, most but NOT all libraries can auto-link their native modules without running react-native link package_name. And from what I've tried myself, since react-native-device-info isn't very actively updating themselves, because there isn't much reason to, they doesn't support the auto-link thing (turns out they do, but maybe on some project it doesn't work as well? at least it doesn't on mine, and I need to link it manually).

Actually, the error message itself is already quite descriptive on how to fix your problem if you actually try reading it carefully.

Linebacker answered 2/8, 2019 at 4:56 Comment(0)
T
2

Isn't available for expo anymore, see this post.

You should be able to replace most common properties with expo-constants and expo-device instead.

Source: https://forums.expo.dev/t/nativemodule-rndeviceinfo-is-null/35351

Titillate answered 28/9, 2021 at 9:4 Comment(0)
P
2

for me , I didn't close the previous bundle of app

Partridge answered 27/10, 2022 at 4:15 Comment(0)
C
2

When I experimented with react-native-device-info I discovered that it only works if you're running it on react-native. If you're running it from expo it will give you an error (RNDeviceInfo is null).

My App didn't work because I created using expo init project-name This will always say that it is not linked with react-native-device-info.

Make sure that the project is installed using react-native.

$ npm i -g create-react-native-app
$ create-react-native-app my-project
$ cd my-project

Then run it on react-native using

npm start

from https://reactnative.dev/blog/2017/03/13/introducing-create-react-native-app

Alternative for react-native-device-info => expo-device (https://docs.expo.dev/versions/latest/sdk/device/#devicebrand)

Coontie answered 14/3, 2023 at 20:0 Comment(0)
T
0

Make sure dependency is linked & rebuild your app after adding the dependency.

Don't forget to run pod install on the iOS folder path.

Telespectroscope answered 25/3, 2022 at 14:43 Comment(0)
C
0

Press

command + shift + k

in Xcode and re run

Corinnecorinth answered 29/3, 2022 at 19:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.