Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: null is not an object (evaluating 'ReactNativeBlobUtil.DocumentDir') #157

Closed
loupmasneri opened this issue May 17, 2022 · 12 comments

Comments

@loupmasneri
Copy link

loupmasneri commented May 17, 2022

I am using react-native-blob-util because rn-fetch-blob has not been updated since 5 years ago and I have this error which happens with rn-fetch-blob too:

TypeError: null is not an object (evaluating 'ReactNativeBlobUtil.DocumentDir')

I am using react-native 0.68.1 and this only happened on android and not iOS.

If someone has already faced the issue.

"react-native": "0.68.1",
"react-native-blob-util": "^0.16.0",

@filiptdz
Copy link

I'm also seeing this issue. Strangely, the problem only happens when I run react-native run-android for an emulator, but install the resulting build to another. Installing to the initial emulator works fine.

@rusty120
Copy link

rusty120 commented Jun 2, 2022

I encountered this as well. It looks like auto linking isn't configured properly for android. I believe to fix this, react and react-native need to be added as dev and peer dependencies to this project. Something like this:

    "devDependencies": {
        ...
        "react": "16.13.1",
        "react-native": "^0.68.2"
    },
    "peerDependencies": {
        "react": "*",
        "react-native": "*"
    }

To work around this before it's fixed, you can configure manually linking. Of course, those instructions aren't quite right either. They reference the old class and package names. Rename :react-native-fetch-blob to :react-native-blob-util and com.RNFetchBlob.RNFetchBlobPackage to com.ReactNativeBlobUtil.ReactNativeBlobUtilPackage and you should be good.

@filiptdz
Copy link

filiptdz commented Jun 2, 2022

fyi the repo I'm working on has an unconventional setup, but I fixed this issue by running react-native bundle

@rusty120
Copy link

rusty120 commented Jun 2, 2022

Oh, I suspect it may also work if you have react-native installed globally. That may be why more people haven't been tripped up by this?

@filiptdz
Copy link

filiptdz commented Jun 2, 2022

Could be, I use npx react-native instead of installing it globally

@RonRadtke
Copy link
Owner

Can you confirm it's working with the peerDependencies? @rusty120 @filiptdz
Porlbme is I wasn't able so far to reproduce it myself

@filiptdz
Copy link

filiptdz commented Jun 7, 2022

@RonRadtke My best guess is this isn't a problem caused by this library, but instead any other issue that causes the React Native bundler not to resolve the native modules. A good solution might be to update it not to crash when the native module isn't found, so people aren't drawn to the conclusion that there may be a problem with this library

@rusty120
Copy link

rusty120 commented Jun 7, 2022

@RonRadtke I can confirm the changes above resolve the issue for me. I pulled the repo and tested it locally. I ended up simply going with manual linking however to avoid having to fork the repo in the short term. If you use npx create-react-native-library ... to create a new node modules you'll notice the template includes react and react-native as peer dependencies, so I'm pretty sure they should be there.

I suspect the issue doesn't happen if you have react-native installed globally or use npx react-native bundle to build, which is maybe why not as many people have been tripped up by this?

@AlixH
Copy link

AlixH commented Jun 28, 2022

I have the same issue with react-native-blob-util 0.13.7 and react native 0.64.3
I don't understand why it occurs without updating anything. It was working before

@ethankong113
Copy link

I tried both adding peerDependencies and manually linking.. neither works for me. Maybe it's because I'm using expo

@RonRadtke
Copy link
Owner

The library doesn't work with expo since it is using native code

@403access
Copy link

Hey together,

had some problems with react-native-pdf which is relying on this library as it seems.

Anyhow, whoever uses Expo might be interested in how to run native code - might help resolving your issues:
wonday/react-native-pdf#624 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants