RN fs:原生模块不能为空



我在博览会上工作,我安装了react-native-fs,我有这个错误:

Invariant Violation: Native module cannot be null.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue

和我的代码:

import fs from 'react-native-fs';
;(async ()=>{
let data = await fs.readFile('./data/user/access.json', 'utf8');
let a = JSON.parse(data);

a.push({
test: 10,
other: true,
string: 'hello world',
});

let json = JSON.stringify(a);

fs.writeFile('./data/user/access.json', json, 'utf8');
})();

它不适用于已管理的项目。如果您必须使用react-native-fs,则需要使用Bare工作流。

欢呼,

最新更新