React-native-fs: undefined is not an object( evaluating’RNFSmanager.RNFSFileTypeRegular’)

Created on 30 May 2018  ·  10Comments  ·  Source: itinance/react-native-fs

undefined is not an object( evaluating’RNFSmanager.RNFSFileTypeRegular’), 只集成了intall 和link 命令

All 10 comments

got the same error here will reply if i find a fix

I've got the same error.

You might this error :
/.../node_modules/react-native-fs/RNFSManager.h:9:9: 'React/RCTBridgeModule.h' file not found

import

If like me you remove the pod dependency to react

I fixed the error by running yarn eject as there is technically no file system as such on the expo version, so if you do yarn eject then either connect your phone via USB and run usb debugging, or start a iOS simulator or android one it will work or did for me

Looks like previous issues reporting this error were frequently with ejected Expo/ CRNA apps. I, too, saw this error after installing and linking on my ExpoKit project. The missing step was restoring my cocoapods after linking.

So, for ExpoKit, the steps are:

  1. NPM/ yarn install
  2. react-native link react-native-fs
  3. Change to the ios directory
  4. pod install

One troublesome thing about this error with respect to CRNA/ Expo is I just noticed is that it happens when you simply import RNFS from 'react-native-fs' without even using it. This means, you can't do something like only turning on your filesystem-API-dependent features based on the availability of the plugin, as you typically can when referencing something from NativeModules), e.g.,

import RNFS from 'react-native-fs';

if (RNFS) {
 // Do file-specific stuff
}

Having the ability to turn off a native module is great if you want to still run most of your code in the Expo client during the development process. I think of it as kind of like being able to build most of a Cordova app by debugging in a web browser, and then only building it into an actual native app when you're ready to test native-specific features/ test end-to-end.

Of course, it's also kind of nice that you get an error when not everything is restored correctly on the native side for when you do intend to run in your actual ExpoKit standalone app.

I fixed it as the following steps:
1、react-native unlink react-native-fs
2、npm uninstall react-native-fs
3、npm i react-native-fs --save
4、react-native link react-native-fs

I also have an ejected Expo -> ExpoKit project, specifically ejected at this stage to utilize react-native-fs, but also getting this error.

At the moment I'm specifically trying to build for Android - however I still get this issue even after uninstalling & relinking the package.

Left a comment here too: https://github.com/itinance/react-native-fs/issues/259

& here's my RN versions:
$ react-native -v
react-native-cli: 2.0.1
react-native: 0.57.1

This command helped me
react-native link react-native-fs

i also got the same issue. after ejected expo successfully react-native link react-native-fs also linked successfully but still the same issue. plz give some solution

In case of iOS message is 'Native module cannot be null', In Android message is 'null is not an object evaluating RNFSManager etc'

Solution for iOS is run pod install in iOS Directory, then react-native run-ios to re-run the app.

Solution for android is react-native link react-native-fs then react-native run-android to re-run the app.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

let-aurn picture let-aurn  ·  3Comments

MuppaAkhil picture MuppaAkhil  ·  3Comments

PimDeWitte picture PimDeWitte  ·  4Comments

ToJen picture ToJen  ·  4Comments

barnir picture barnir  ·  3Comments