尝试使用 aws amplify 部署使用 Metro Bunler 的 expo 50.0.5 React Native Web 应用程序在构建步骤中失败

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

我无法使用 Metro Bunler 将 expo 50.0.5 React 本机 Web 应用程序部署到 AWS amplify。

详情:

在我的本地机器上(它可以工作):

节点:v21.1.0

Npm:10.2.0

世博会": "~50.0.5

设置:

Package.json
{
  "name": "reactnativewebapp",
  "version": "1.0.0",
  "main": "expo-router/entry",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "~50.0.5",
    "expo-status-bar": "~1.11.1",
    "react": "18.2.0",
    "react-native": "0.73.4",
    "react-native-web": "~0.19.6",
    "react-dom": "18.2.0",
    "@expo/metro-runtime": "~3.1.1",
    "expo-router": "~3.4.6",
    "react-native-safe-area-context": "4.8.2",
    "react-native-screens": "~3.29.0",
    "expo-linking": "~6.2.2",
    "expo-constants": "~15.4.5"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

我运行来创建 dist 的命令:

npx expo 导出-p web

AWS Amplify(构建失败):


version: 1
frontend:
  phases:
    preBuild:
      commands:
        - nvm install 18
        - nvm use 18
        - npm install --silent --global expo-cli
        - npm install
    build:
      commands:
        - 'expo export -p web'
  artifacts:
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
      - $(npm root --global)/**/*

AWS BUILD 中的错误日志:

2024-02-08T00:03:42.749Z [INFO]: Now using node v18.19.0 (npm v)
2024-02-08T00:03:42.779Z [INFO]: Installing default global packages from /root/.nvm/default-packages...
2024-02-08T00:03:42.780Z [INFO]: npm install -g --quiet [email protected]
2024-02-08T00:03:42.783Z [WARNING]: node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
                                    node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
2024-02-08T00:03:42.784Z [WARNING]: Failed installing default packages. Please check if your default-packages file or a package in it has problems!
2024-02-08T00:03:42.785Z [INFO]: # Executing command: nvm use 18
2024-02-08T00:03:43.293Z [INFO]: Now using node v18.19.0 (npm v)
2024-02-08T00:03:43.293Z [INFO]: # Executing command: npm install --silent --global expo-cli
2024-02-08T00:03:43.294Z [WARNING]: node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
                                    node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
2024-02-08T00:03:43.296Z [ERROR]: !!! Build failed
2024-02-08T00:03:43.296Z [ERROR]: !!! Error: Command failed with exit code 1
amazon-web-services react-native web expo aws-amplify
1个回答
0
投票

也许你可以尝试将构建镜像更改为最新的。

例如: Amazon Linux 2023(默认)

参考: https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-image.html

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