运行expo React Native ios应用程序时AppEntry捆绑问题

问题描述 投票:0回答:1

因此,我按照 AWS Amplify 文档创建一个 React Native expo 应用程序。 (https://docs.amplify.aws/react-native/start/getting-started/setup/

我已经安装了一个用于 graphQL(生成打字稿)存储和身份验证的 api。

包.json

{
  "name": "gimme-golf",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@aws-amplify/react-native": "^1.0.28",
    "@aws-amplify/ui-react-native": "^2.1.6",
    "@react-native-async-storage/async-storage": "^1.23.1",
    "@react-native-community/netinfo": "^11.3.1",
    "@types/react": "~18.2.45",
    "aws-amplify": "^6.2.0",
    "babel-plugin-module-resolver": "^5.0.2",
    "expo": "~50.0.17",
    "expo-status-bar": "~1.11.1",
    "react": "18.2.0",
    "react-native": "0.73.6",
    "react-native-get-random-values": "^1.11.0",
    "react-native-safe-area-context": "4.8.2",
    "typescript": "^5.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

应用程序.js

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import {
  withAuthenticator,
  useAuthenticator
} from '@aws-amplify/ui-react-native';

import { Amplify } from 'aws-amplify';
import amplifyconfig from './src/amplifyconfiguration.json';
Amplify.configure(amplifyconfig);

// retrieves only the current value of 'user' from 'useAuthenticator'
const userSelector = (context) => [context.user];

const SignOutButton = () => {
  const { user, signOut } = useAuthenticator(userSelector);
  return (
    <Pressable onPress={signOut} style={styles.buttonContainer}>
      <Text style={styles.buttonText}>
        Hello, {user.username}! Click here to sign out!
      </Text>
    </Pressable>
  );
};

const App = () => {
  return (
    <SafeAreaView style={styles.container}>
    <View style={styles.container}>
      <SignOutButton />
    </View>
  </SafeAreaView>
  );
}
export default withAuthenticator(App);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

我尝试删除node_modules和package-lock.json并使用npm i和npx expo install重新安装。

无论我尝试什么,我总是会得到不同的结果

iOS Bundling failed 4396ms (node_modules/expo/AppEntry.js)
Unable to resolve "@babel/runtime/helpers/classCallCheck" from "node_modules/react-native/Libraries/Components/Button.js"

它无法解决更改的区域,但它始终无法捆绑。到目前为止,我所做的一切都是按照文档进行的。并在安装 auth 和 api 后尝试运行。

ios react-native expo aws-amplify
1个回答
0
投票

检查

./src/amplifyconfiguration.json
是否存在,如果不存在则执行
 npx ampx sandbox
生成文件。

© www.soinside.com 2019 - 2024. All rights reserved.