Aws-amplify 不适用于 react-native 和 expo 版本 36.0.0
Aws-amplify not working with react-native and expo version 36.0.0
我目前正在使用 expoSdk 开发一个 react-native-app,它应该在网络上 运行,ios 和 android。到目前为止,最具挑战性的部分是设置导航,我终于做到了。现在我将 amplify 添加到我的项目中,但是每当我 运行 它在任何移动设备上时项目都会停止工作,但它在网络上工作得很好。我收到的错误是
NetInfo has been removed from React Native
经过大量试验和错误后,我发现错误来自 aws-amplify,因为它似乎仍然 运行 和 reac-native-community/netinfo
。该错误仅在我从 amplify 导入某些内容时发生。我在
中找到了这个
node_modules\@aws-amplify\core\lib\Util\Reachability.native.js
谁知道我该如何解决这个问题?
如果需要,这是我的package.json
"dependencies": {
"@expo/vector-icons": "~10.0.0",
"aws-amplify": "^2.2.6",
"@react-native-community/masked-view": "0.1.5",
"@react-navigation/bottom-tabs": "^5.0.0",
"@react-navigation/drawer": "^5.2.0",
"@react-navigation/native": "^5.0.0",
"@react-navigation/stack": "^5.0.0",
"@react-navigation/web": "~1.0.0-alpha.9",
"expo": "~36.0.0",
"expo-asset": "~8.0.0",
"expo-constants": "~8.0.0",
"expo-font": "~8.0.0",
"expo-web-browser": "~8.0.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"react-native-gesture-handler": "~1.5.0",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "0.6.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-web": "~0.11.7",
"react-spring": "^8.0.27",
"styled-components": "^5.0.1",
"@aws-amplify/api": "^2.1.6",
"@aws-amplify/pubsub": "^2.1.7",
"@expo/samples": "^3.0.3",
"apollo-boost": "^0.4.3",
"apollo-cache-inmemory": "^1.6.2",
"apollo-client": "^2.6.3",
"apollo-link-http": "^1.5.15",
"aws-amplify-react-native": "^3.2.2",
"aws-appsync": "^1.7.0",
"aws-appsync-react": "^1.2.5",
"expo-av": "~8.0.0",
"expo-camera": "~8.0.0",
"expo-file-system": "~8.0.0",
"expo-image-picker": "~8.0.1",
"expo-permissions": "~8.0.0",
"graphql-tag": "^2.10.1",
"moment": "^2.20.1",
"prop-types": "^15.7.2",
"react-apollo": "^2.0.4",
"react-native-datepicker": "^1.7.2",
"react-native-deck-swiper": "^1.6.7",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-material-dropdown": "^0.11.1",
"react-native-modal": "^11.3.1",
"react-native-modal-datetime-picker": "^4.13.0",
"react-native-modal-dropdown": "^0.6.2",
"react-native-paper": "^2.16.0",
"react-native-responsive-screen": "^1.4.0",
"react-native-segmented-control-tab": "^3.4.1",
"react-native-slideable-calendar-strip": "^0.4.0",
"react-native-snap-carousel": "^3.8.0",
"react-native-sound": "^0.11.0",
"react-native-svg": "9.13.3",
"react-native-swipe-gestures": "^1.0.3",
"react-native-swipeable": "^0.6.0",
"react-native-swipeout": "^2.3.3",
"react-native-touchable-swipe": "^1.0.0",
"react-navigation": "^4.2.2",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-persist": "^4.10.2",
"redux-thunk": "^2.3.0",
"uuid": "^3.2.1"
},
非常感谢任何帮助。
万一有人遇到这个问题,这是@Ashish-Nanda 在 github 上的解决方案:
您链接的问题有包维护者的回复,其中包含错误原因。
您的一个或多个依赖项可能正在从 React Native 核心导入 NetInfo。查看您的 package.json,其中之一是 aws-appsync-react,您需要升级到 2.x.x 以上的任何版本。从您的 package.json 中删除 aws-appsync-react 和 aws-appsync 并安装最新版本(确保其高于 2.x.x)。然后做:
npm install --save @react-native-community/netinfo@4.7.0
您需要安装此特定版本,因为较新的版本会导致 API 更改时出现问题。
我目前正在使用 expoSdk 开发一个 react-native-app,它应该在网络上 运行,ios 和 android。到目前为止,最具挑战性的部分是设置导航,我终于做到了。现在我将 amplify 添加到我的项目中,但是每当我 运行 它在任何移动设备上时项目都会停止工作,但它在网络上工作得很好。我收到的错误是
NetInfo has been removed from React Native
经过大量试验和错误后,我发现错误来自 aws-amplify,因为它似乎仍然 运行 和 reac-native-community/netinfo
。该错误仅在我从 amplify 导入某些内容时发生。我在
node_modules\@aws-amplify\core\lib\Util\Reachability.native.js
谁知道我该如何解决这个问题?
如果需要,这是我的package.json
"dependencies": {
"@expo/vector-icons": "~10.0.0",
"aws-amplify": "^2.2.6",
"@react-native-community/masked-view": "0.1.5",
"@react-navigation/bottom-tabs": "^5.0.0",
"@react-navigation/drawer": "^5.2.0",
"@react-navigation/native": "^5.0.0",
"@react-navigation/stack": "^5.0.0",
"@react-navigation/web": "~1.0.0-alpha.9",
"expo": "~36.0.0",
"expo-asset": "~8.0.0",
"expo-constants": "~8.0.0",
"expo-font": "~8.0.0",
"expo-web-browser": "~8.0.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"react-native-gesture-handler": "~1.5.0",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "0.6.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-web": "~0.11.7",
"react-spring": "^8.0.27",
"styled-components": "^5.0.1",
"@aws-amplify/api": "^2.1.6",
"@aws-amplify/pubsub": "^2.1.7",
"@expo/samples": "^3.0.3",
"apollo-boost": "^0.4.3",
"apollo-cache-inmemory": "^1.6.2",
"apollo-client": "^2.6.3",
"apollo-link-http": "^1.5.15",
"aws-amplify-react-native": "^3.2.2",
"aws-appsync": "^1.7.0",
"aws-appsync-react": "^1.2.5",
"expo-av": "~8.0.0",
"expo-camera": "~8.0.0",
"expo-file-system": "~8.0.0",
"expo-image-picker": "~8.0.1",
"expo-permissions": "~8.0.0",
"graphql-tag": "^2.10.1",
"moment": "^2.20.1",
"prop-types": "^15.7.2",
"react-apollo": "^2.0.4",
"react-native-datepicker": "^1.7.2",
"react-native-deck-swiper": "^1.6.7",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-material-dropdown": "^0.11.1",
"react-native-modal": "^11.3.1",
"react-native-modal-datetime-picker": "^4.13.0",
"react-native-modal-dropdown": "^0.6.2",
"react-native-paper": "^2.16.0",
"react-native-responsive-screen": "^1.4.0",
"react-native-segmented-control-tab": "^3.4.1",
"react-native-slideable-calendar-strip": "^0.4.0",
"react-native-snap-carousel": "^3.8.0",
"react-native-sound": "^0.11.0",
"react-native-svg": "9.13.3",
"react-native-swipe-gestures": "^1.0.3",
"react-native-swipeable": "^0.6.0",
"react-native-swipeout": "^2.3.3",
"react-native-touchable-swipe": "^1.0.0",
"react-navigation": "^4.2.2",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-persist": "^4.10.2",
"redux-thunk": "^2.3.0",
"uuid": "^3.2.1"
},
非常感谢任何帮助。
万一有人遇到这个问题,这是@Ashish-Nanda 在 github 上的解决方案:
您链接的问题有包维护者的回复,其中包含错误原因。 您的一个或多个依赖项可能正在从 React Native 核心导入 NetInfo。查看您的 package.json,其中之一是 aws-appsync-react,您需要升级到 2.x.x 以上的任何版本。从您的 package.json 中删除 aws-appsync-react 和 aws-appsync 并安装最新版本(确保其高于 2.x.x)。然后做:
npm install --save @react-native-community/netinfo@4.7.0
您需要安装此特定版本,因为较新的版本会导致 API 更改时出现问题。