React Native:导入 react-native-fetch-blob 时无法读取未定义的 属性 'Document Dir'

React Native : Cannot read property 'Document Dir' of undefined when importing react-native-fetch-blob

我试图在我的项目中使用 react-native-fetch-blob,但是每当我把一个

import RNFetchBlob from 'react-native-fetch-blob'

我在模拟器上收到错误消息

Cannot read property 'Document Dir' of undefined

我已经使用

安装了它
npm i --save react-native-fetch-blob

并使用

链接它
react-native link

错误:

Cannot read property 'DocumentDir' of undefined fs.js:24:31 loadModuleImplementation require.js:214:4 guardedLoadModule require.js:148:11 _require require.js:132:2 index.js:21 loadModuleImplementation require.js:214:4 guardedLoadModule require.js:148:11 _require require.js:132:2 App.js:6 loadModuleImplementation require.js:214:4

安装并链接包后。执行以下操作

watchman watch-del-all

npm cache clean --force

rm -f /ios/build(如果您正在为 ios 构建) rm -f /android/build(如果您正在为 android 构建)

react-native run-ios `or` react-native run-ios

希望它能解决您的问题