【问题标题】:RN fs: Native module cannot be nullRN fs:本机模块不能为空
【发布时间】: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


【解决方案1】:

它不适用于托管项目。如果您需要使用 react-native-fs,则需要使用 Bare 工作流程。

干杯,

【讨论】:

    猜你喜欢
    • 2021-11-04
    • 1970-01-01
    • 2016-09-17
    • 1970-01-01
    • 1970-01-01
    • 2019-05-21
    • 2020-12-13
    • 1970-01-01
    • 2018-07-10
    相关资源
    最近更新 更多