【发布时间】:2021-08-08 15:18:17
【问题描述】:
我在 expo 上工作,我安装了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');
})();
【问题讨论】:
-
这里有同样的问题,您可以检查一下是否有帮助。 here
标签: javascript node.js reactjs react-native