React-native-fs: Cannot read property 'RNFSFileTypeRegular' of undefined on typescript

Created on 2 Jul 2019  路  5Comments  路  Source: itinance/react-native-fs

I've got Cannot read property 'RNFSFileTypeRegular' of undefined after running app on ios, I'm using type script and also I follow the README file For RN >= 0.57 and/or Gradle >= 3 you MUST install react-native-fs at version @2.13.2!, here is my code:

 constructor(props) {
        super(props);
        RNFS.readDir(RNFS.MainBundlePath) // On Android, use "RNFS.DocumentDirectoryPath" (MainBundlePath is not defined)
            .then((result) => {
                console.log('GOT RESULT', result);

                // stat the first file
                return Promise.all([RNFS.stat(result[0].path), result[0].path]);
            })
            .then((statResult) => {
                if (statResult[0].isFile()) {
                    // if we have a file, read it
                    return RNFS.readFile(statResult[1], 'utf8');
                }

                return 'no file';
            })
            .then((contents) => {
                // log the file contents
                console.log(contents);
            })
            .catch((err) => {
                console.log(err.message, err.code);
            });
        this.state = {};
    }

Most helpful comment

I am facing same issue in android. Any help?

All 5 comments

I have the same issue when run in android device using 'expo start',
could you solved the problem?

thanks in advance

React-Native version 0.60

I'm experiencing this building a new [email protected] app from scratch and including the react-native-fs module.

NOTE: this only affects a new app on iOS (Android works fine)

UPDATE: I was able to fix this issue by adding pod 'RNFS', :path => '../node_modules/react-native-fs' to a new project's Podfile which is in the instructions for linking manually with Pods. It seems the auto-linking feature in [email protected] doesn't succeed for iOS.

For me I had to delete Podfile.lock file AND Pods dir, then the issue was resolved.

I am facing same issue in android. Any help?

The following two commands fixed it for me:
react-native unlink react-native-fs
react-native link react-native-fs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wangfpp picture wangfpp  路  3Comments

AgNm picture AgNm  路  4Comments

CesarLanderos picture CesarLanderos  路  4Comments

let-aurn picture let-aurn  路  3Comments

duckmyanmar picture duckmyanmar  路  3Comments