I am trying to automatically publish my app on expo when pushing on the main branch. When I try locally my app gets published correctly, but the build fails on the CI, because it is unable to resolve my components:
expo publish --non-interactive --release-channel default
shell: /usr/bin/bash -e {0}
env:
EXPO_TOKEN: ***
[16:28:25] › Expo SDK: 44.0.0
[16:28:25] › Release channel: default
[16:28:25] › Workflow: Managed
[16:28:25] Building optimized bundles and generating sourcemaps...
[16:28:27] Starting Metro Bundler
[16:30:13] Unable to resolve module ../../components/form-controls/button from /home/runner/work/my-app/my-app/src/views/authentication/login.tsx:
None of these files exist:
* src/components/form-controls/button(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
* src/components/form-controls/button/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
> 1 | import { useContext, useMemo, useState } from 'react';
2 | import { StyleSheet, Text, View } from 'react-native';
3 | import Button from '@components/form-controls/button';
4 | import Input from '@components/form-controls/input';
[16:30:13] Error: Unable to resolve module ../../components/form-controls/button from /home/runner/work/my-app/my-app/src/views/authentication/login.tsx:
None of these files exist:
* src/components/form-controls/button(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
* src/components/form-controls/button/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
> 1 | import { useContext, useMemo, useState } from 'react';
2 | import { StyleSheet, Text, View } from 'react-native';
3 | import Button from '@components/form-controls/button';
4 | import Input from '@components/form-controls/input';
at ModuleResolver.resolveDependency (/home/runner/work/my-app/vmy-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:211:15)
at DependencyGraph.resolveDependency (/home/runner/work/my-app/my-app/node_modules/metro/src/node-haste/DependencyGraph.js:413:43)
at Object.resolve (/home/runner/work/my-app/my-app/node_modules/metro/src/lib/transformHelpers.js:317:42)
at resolve (/home/runner/work/my-app/my-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:629:33)
at /home/runner/work/my-app/my-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:645:26
at Array.reduce (<anonymous>)
at resolveDependencies (/home/runner/work/my-app/my-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:644:33)
at /home/runner/work/my-app/my-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:329:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (/home/runner/work/my-app/my-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:24)
Error: Process completed with exit code 1.
I am using expo/expo-github-action@v7, here are the logs of the expo setup step:
Run expo/expo-github-action@v7
Installing expo-cli (5.3.2) from cache or with yarn
Received 23905004 of 23905004 (100.0%), 24.6 MBs/sec
Cache Size: ~23 MB (23905004 B)
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/5d58b0d1-b4da-4201-8eb9-f28763655d2b/cache.tzst -P -C /home/runner/work/vozik-app/vozik-app
Cache restored successfully
Installing eas-cli (0.51.0) from cache or with yarn
Validating authenticated account
Patching system watchers for the 'ENOSPC' error
Here is my babel.config.js file:
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
["module:react-native-dotenv", {
envName: "APP_ENV",
moduleName: "@env",
path: ".env",
blocklist: null,
allowlist: null,
safe: false,
allowUndefined: true,
verbose: false
}],
["module-resolver", {
root: ["./"],
alias: {
"@components": "./src/components",
"@interfaces": "./src/interfaces",
"@services": "./src/services",
"@state": "./src/state",
"@utils": "./src/utils",
"@views": "./src/views"
}
}],
]
};
};
I was initially using relative paths to imports these modules, and then tried to use aliases instead, but it did not change anything. The expo SDK is 44.0.0 and expo-cli's version if 5.3.2 (locally and on github actions). Also, the file src/components/form-controls/button.tsx
does exist, and the path is correct. I would like to understand why the build is working locally, but fails on the CI?
Thanks in advance