博览会-根据需要反应本机文件系统错误

问题描述

我不需要react-native-fs,应用会引发异常:

'main' has not been registered. This can happen if: 
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running,stop it and restart it in the current project. 
* A module Failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

我按照官方文档中的指南进行安装。

App.js:

import React from 'react';
import { View } from 'react-native';

const RNFS = require("react-native-fs");

export default function App() {
  return (

    <View>

    </View>

  );
}

package.json:

{
  "main": "index.js","scripts": {
    "android": "react-native run-android","ios": "react-native run-ios","web": "expo start --web","start": "react-native start","test": "jest"
  },"dependencies": {
    "expo": "~39.0.2","expo-splash-screen": "~0.6.0","expo-status-bar": "~1.0.2","expo-updates": "~0.3.2","react": "16.13.1","react-dom": "16.13.1","react-native": "~0.63.2","react-native-fs": "^2.16.6","react-native-gesture-handler": "~1.7.0","react-native-reanimated": "~1.13.0","react-native-screens": "~2.10.1","react-native-unimodules": "~0.11.0","react-native-web": "~0.13.12"
  },"devDependencies": {
    "@babel/core": "~7.9.0","babel-jest": "~25.2.6","jest": "~25.2.6","react-test-renderer": "~16.13.1"
  },"jest": {
    "preset": "react-native"
  },"private": true
}

很明显,如果我删除require行,则错误消失了。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)