反应原生错误:模糊分辨率

时间:2018-03-28 20:54:53

标签: xcode react-native node-modules

当我尝试在iOS模拟器上运行我的React Native应用程序时,我出现了一个红色屏幕,出现以下错误:

  

模棱两可的解决方案:模块   ' /Users/my-user/Documents/my-RN-app/app/index.js'试图要求   ' react-native-vector-icons',但有几个文件提供   这个模块。您可以删除或修复它们:

     

/Users/my-user/Documents/my-RN-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app/my-RN-app/node_modules/react-native/local-cli/芯/ __夹具__ /文件/的package.json

     

/用户/我的用户/文档/我的-RN-应用程序/ node_modules /反应天然/本地CLI /核心/ __夹具__ /文件/的package.json

但是,上述两个文件(package.json文件)都丢失了。我之前实际上遇到过这个错误,所以我决定在上面提到的第一个目录位置(在ios / build / ..等下面)删除package.json文件并刷新应用程序,它加载得很好。现在,在尝试再次在iOS模拟器中启动我的应用程序后,我又回到了同样的错误,但是我无法删除package.json文件,因为它现在在任何一个位置都不存在。

我试图在我的app / index.js文件中注释掉react-native-vector-icons lib的导入并重新启动SIM卡,但错误仍然出现。

最后,我试过这个:

  1. sudo rm -rf node_modules(我得到"权限被拒绝"如果我不使用sudo,虽然看起来我对所有文件/文件夹都有完整的读/写权限这个项目)
  2. sudo rm -rf ios/build
  3. npm install
  4. cd ios && pod install
  5. react-native link
  6. 然后回到Xcdoe:产品>清洁,然后再次运行模拟器。仍然是同样的错误。

    根据要求,这是我的package.json文件:

     {
      "name": "myApp",
      "version": "0.0.1",
      "private": true,
      "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "run-ios": "node_modules/.bin/react-native run-ios",
      },
      "dependencies": {
        "art": "^0.10.1",
        "auto-bind": "^1.1.0",
        "axios": "^0.16.1",
        "eslint-plugin-react-native": "^2.3.1",
        "jwt-decode": "^2.2.0",
        "moment": "^2.19.1",
        "native-base": "^2.3.1",
        "prop-types": "^15.5.8",
        "pubnub": "^4.18.0",
        "react": "^16.0.0",
        "react-native": "^0.49.3",
        "react-native-actionsheet": "^2.3.0",
        "react-native-device-info": "^0.11.0",
        "react-native-fabric": "^0.5.1",
        "react-native-fingerprint-scanner": "^2.2.1",
        "react-native-flip-card": "^3.5.2",
        "react-native-google-analytics-bridge": "^5.3.3",
        "react-native-haptic": "^1.0.5",
        "react-native-image-base64": "^0.1.3",
        "react-native-image-picker": "^0.26.7",
        "react-native-image-resizer": "^1.0.0",
        "react-native-keyboard-aware-scroll-view": "^0.4.3",
        "react-native-keyboard-spacer": "^0.4.1",
        "react-native-keychain": "^1.2.1",
        "react-native-maps": "^0.17.1",
        "react-native-modal-dropdown": "^0.5.0",
        "react-native-mplayer": "^1.0.1",
        "react-native-notifications-badge-extensions": "^1.0.5",
        "react-native-permissions": "^0.2.7",
        "react-native-pie": "^0.4.0",
        "react-native-router-flux": "^4.0.0-beta.26",
        "react-native-snap-carousel": "^3.2.3",
        "react-native-tag-input": "0.0.18",
        "react-native-tooltip": "^5.2.0",
        "react-native-uuid-generator": "^3.0.2",
        "react-native-vector-icons": "^4.3.0",
        "react-native-version-number": "^0.1.3",
        "react-native-voice": "^0.2.5",
        "react-navigation": "^1.2.0",
        "sprintf-js": "^1.0.3",
        "validator": "^9.2.0"
      },
      "devDependencies": {
        "babel-jest": "18.0.0",
        "babel-preset-react-native": "^4.0.0",
        "enzyme": "^3.3.0",
        "enzyme-adapter-react-16": "^1.1.1",
        "enzyme-to-json": "^3.3.1",
        "eslint": "^3.14.1",
        "eslint-config-airbnb": "^14.1.0",
        "eslint-plugin-import": "^2.2.0",
        "eslint-plugin-jsx-a11y": "^4.0.0",
        "eslint-plugin-react": "^7.5.1",
        "jest": "18.1.0",
        "jest-serializer-enzyme": "^1.0.0",
        "jsdom": "11.6.2",
        "jsdom-global": "3.0.2",
        "metro-bundler": "^0.20.0",
        "react-addons-test-utils": "^15.6.2",
        "react-dom": "^16.2.0",
        "react-native-mock": "^0.3.1",
        "react-test-renderer": "16.0.0-alpha.12",
        "sinon": "^4.1.2"
      },
      "resolutions": {
        "moment": "2.19.1"
      }
    }
    

1 个答案:

答案 0 :(得分:1)

我不得不手动将React pod链接到node_modules

pod 'React', :path => '../node_modules/react-native'

然后清理并重新构建