gpt4 book ai didi

ios - Expo 构建在 CI 中失败,但在本地构建(babel-preset-expo 已被忽略,因为它包含无效配置)

转载 作者:行者123 更新时间:2023-12-03 14:22:12 24 4
gpt4 key购买 nike

它的经典案例适用于我的机器。我正在构建两个 react native 应用程序。应用程序 A 和应用程序 B。这两个应用程序都是使用 expo 引导的。 。

当我运行命令在本地构建任一应用程序时,它们都会构建。然而,当我尝试在 gitlab-ci 中构建应用程序时,只有应用程序 B 无法构建并显示以下消息:

[23:07:28] warn Package babel-preset-expo has been ignored because it contains invalid configuration. Reason: Cannot find module 'babel-preset-expo/package.json'
[23:07:28] Require stack:
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/@react-native-community/cli/build/tools/config/resolveNodeModuleDir.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/@react-native-community/cli/build/tools/releaseChecker/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/runServer.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/server.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/local-cli/cli.js
[23:07:28]
[23:07:29] Starting Metro Bundler on port 19001.
[23:07:29] debug Watch mode is not supported in this environment
[23:07:29] debug Checking for a newer version of React Native
[23:07:29] debug Current version: 0.61.4
[23:07:29] debug No release cache found
[23:07:29] debug No release cache found
[23:07:29] debug Checking for newer releases on GitHub
[23:07:29] debug No release cache found
[23:07:30] Publishing to channel 'default'...
[23:07:30] debug Saving "6d6386b01438c6ef0acd213d304b5839" to cache
[23:07:30] debug No release cache found
[23:07:30] debug No release cache found
[23:07:30] debug Latest release: 0.60.0
[23:07:32] Building iOS bundle
[23:07:43] node_modules/expo/AppEntry.js: Cannot find module 'babel-preset-expo' from '/builds/XXX/application-b'
[23:07:43] › Closing Expo server
[23:07:43] node_modules/expo/AppEntry.js: Cannot find module 'babel-preset-expo' from '/builds/XXX/application-b'
[23:07:43] Failed building JavaScript bundle.
[23:07:43] ::ffff:127.0.0.1 - - [06/Apr/2020:23:07:43 +0000] "GET /node_modules/expo/AppEntry.bundle?dev=false&minify=true&hot=false&platform=ios HTTP/1.1" 500 - "-" "axios/0.19.0"
[23:07:43] › Stopping Metro bundler
[23:07:43] Packager URL http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?dev=false&minify=true&hot=false&platform=ios returned unexpected code 500. Please open your project in the Expo app and see if there are any errors. Also scroll up and make sure there were no errors or warnings when opening your project.

我尝试让 CI 显式安装模块 babel-preset-expo,但这并不能解决问题。我的 babel.config.js 对于这两个应用程序来说是相同的,如下所示:

module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};

我的两个 package.json 中都有以下几行:

  "devDependencies": {
"@babel/core": "^7.0.0",
"babel-preset-expo": "^8.0.0"
},

错误 AppEntry.js 中引用的两个应用程序中的文件也相同。

这是我的 gitlab-ci.yml:

image: node/alpine
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- ~/.npm

stages:
- deploy
- tag
before_script:
- echo $CI_BUILD_REF
- echo $CI_PROJECT_DIR
- apk add --no-cache bash build-base gcc git python3 curl
- PATCH=`git log --pretty=oneline | wc -l | sed -e 's/^[[:space:]]*//'`
- VERSION=`cat VERSION`
- VERSION=${VERSION%?}
- TAG="${VERSION}${PATCH}"
- echo "Build version = ${TAG}"

expo-build:
stage: deploy
artifacts:
paths:
- ipas/
script:
- sed -i "s/0.0.0/${TAG}/g" app.json
- npm ci --production --cache .npm --prefer-offline
- npx expo login -u $EXPO_USERNAME -p $EXPO_PASSWORD
- EXPO_DEBUG=true npx expo build:ios --non-interactive # This works because it has been already built once through the cli, credentials cannot be pass into env
- mkdir -p ipas
- curl "$(npx expo url:ipa --non-interactive)" -o ipas/bravo-teller-$TAG.ipa
only:
- master

任何关于这可能是什么的反馈或建议将不胜感激。谢谢

最佳答案

实际上,babel-preset-expo不是 devDependencies,您应该将其添加到 dependency 中,而且您可能应该在 babel 配置上使用以下代码来使用延迟加载:

[
'babel-preset-expo',
{
lazyImports: true,
},
]

关于ios - Expo 构建在 CI 中失败,但在本地构建(babel-preset-expo 已被忽略,因为它包含无效配置),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61070536/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com