Run gradlew always fails "Error: Unable to resolve module"

Every other phase of the build runs flawlessly but it always fails at Task :app:createBundleReleaseJsAndAssets even though my javascript bundles just fine and it doesn’t explicitly state that it failed.

Here is a repository with the source code: https://github.com/Natalius-dev/temp_expo_post

Here is a link to the build page if any expo employees see this: https://expo.dev/accounts/natalius_dev/projects/cc-cup-2023/builds/86000446-8803-4f29-831e-d0af42221027

> Task :app:createBundleReleaseJsAndAssets

warning: Bundler cache is empty, rebuilding (this may take a minute)

[stderr] 

Error: Unable to resolve module ./lib/colors from /home/expo/workingdir/build/frontend/app/App.js: 

[stderr] 

None of these files exist:

[stderr] 

  * lib/colors(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)

[stderr] 

  * lib/colors/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)

[stderr] 

  1 | import { StatusBar, StyleSheet, Text, TextInput, View } from 'react-native';

[stderr] 

> 2 | import { colors } from './lib/colors';

[stderr] 

    |                         ^

[stderr] 

  3 | import { fonts } from './lib/fonts';

[stderr] 

  4 | import { useFonts } from 'expo-font';

[stderr] 

  5 | import { SafeAreaView } from 'react-native-safe-area-context';

[stderr] 

Error: Unable to resolve module ./lib/colors from /home/expo/workingdir/build/frontend/app/App.js: 

[stderr] 

None of these files exist:

[stderr] 

  * lib/colors(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)

[stderr] 

  * lib/colors/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)

[stderr] 

  1 | import { StatusBar, StyleSheet, Text, TextInput, View } from 'react-native';

[stderr] 

> 2 | import { colors } from './lib/colors';

[stderr] 

    |                         ^

[stderr] 

  3 | import { fonts } from './lib/fonts';

[stderr] 

  4 | import { useFonts } from 'expo-font';

[stderr] 

  5 | import { SafeAreaView } from 'react-native-safe-area-context';

[stderr] 

    at ModuleResolver.resolveDependency (/home/expo/workingdir/build/frontend/app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:114:15)

[stderr] 

    at DependencyGraph.resolveDependency (/home/expo/workingdir/build/frontend/app/node_modules/metro/src/node-haste/DependencyGraph.js:277:43)

[stderr] 

    at Object.resolve (/home/expo/workingdir/build/frontend/app/node_modules/metro/src/lib/transformHelpers.js:169:21)

[stderr] 

    at Graph._resolveDependencies (/home/expo/workingdir/build/frontend/app/node_modules/metro/src/DeltaBundler/Graph.js:473:35)

[stderr] 

    at Graph._processModule (/home/expo/workingdir/build/frontend/app/node_modules/metro/src/DeltaBundler/Graph.js:261:38)

[stderr] 

    at processTicksAndRejections (node:internal/process/task_queues:96:5)

[stderr] 

    at async Graph._addDependency (/home/expo/workingdir/build/frontend/app/node_modules/metro/src/DeltaBundler/Graph.js:372:20)

[stderr] 

    at async Promise.all (index 2)

[stderr] 

    at async Graph._processModule (/home/expo/workingdir/build/frontend/app/node_modules/metro/src/DeltaBundler/Graph.js:322:5)

[stderr] 

    at async Graph._traverseDependenciesForSingleFile (/home/expo/workingdir/build/frontend/app/node_modules/metro/src/DeltaBundler/Graph.js:249:5)

> Task :app:createBundleReleaseJsAndAssets FAILED

> Task :react-native-async-storage_async-storage:generateReleaseRFile

[stderr] 

FAILURE: Build failed with an exception.

[stderr] 

* What went wrong:

[stderr] 

Execution failed for task ':app:createBundleReleaseJsAndAssets'.

[stderr] 

> Process 'command 'node'' finished with non-zero exit value 1

[stderr] 

* Try:

[stderr] 

> Run with --stacktrace option to get the stack trace.

[stderr] 

> Run with --info or --debug option to get more log output.

[stderr] 

> Run with --scan to get full insights.

[stderr] 

* Get more help at https://help.gradle.org

[stderr] 

BUILD FAILED in 3m 18s

96 actionable tasks: 96 executed

Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

Hi @natalius_dev

I cloned your test repository and tried building it. It seems the repository is missing a couple of dependencies. After I installed react-native-tab-view and react-native-pager-view it built fine for me.

Here’s the diff:

diff --git package-lock.json package-lock.json
index 83d0e35..0c61a86 100644
--- package-lock.json
+++ package-lock.json
@@ -24,10 +24,12 @@
         "expo-status-bar": "~1.6.0",
         "react": "18.2.0",
         "react-native": "0.72.4",
+        "react-native-pager-view": "6.2.0",
         "react-native-paper": "^5.10.1",
         "react-native-safe-area-context": "4.6.3",
         "react-native-screens": "~3.22.0",
         "react-native-svg": "13.9.0",
+        "react-native-tab-view": "^3.5.2",
         "react-native-vector-icons": "^10.0.0",
         "react-native-webview": "13.2.2",
         "react-native-youtube-iframe": "^2.3.0"
@@ -12641,10 +12643,9 @@
       }
     },
     "node_modules/react-native-pager-view": {
-      "version": "6.2.1",
-      "resolved": "https://registry.npmjs.org/react-native-pager-view/-/react-native-pager-view-6.2.1.tgz",
-      "integrity": "sha512-fZ8chez5J+w831nSnbtK8hwlCiMy1DgpFv8xG6ajXLsAI8uMkGvP554QDIDNlUoCuVwMf7OFyd32Y2Nm2Iaj9Q==",
-      "peer": true,
+      "version": "6.2.0",
+      "resolved": "https://registry.npmjs.org/react-native-pager-view/-/react-native-pager-view-6.2.0.tgz",
+      "integrity": "sha512-pf9OnL/Tkr+5s4Gjmsn7xh91PtJLDa6qxYa/bmtUhd/+s4cQdWQ8DIFoOFghwZIHHHwVdWtoXkp6HtpjN+r20g==",
       "peerDependencies": {
         "react": "*",
         "react-native": "*"
@@ -12714,7 +12715,6 @@
       "version": "3.5.2",
       "resolved": "https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-3.5.2.tgz",
       "integrity": "sha512-nE5WqjbeEPsWQx4mtz81QGVvgHRhujTNIIZiMCx3Bj6CBFDafbk7XZp9ocmtzXUQaZ4bhtVS43R4FIiR4LboJw==",
-      "peer": true,
       "dependencies": {
         "use-latest-callback": "^0.1.5"
       },
diff --git package.json package.json
index 838f46f..c7efd65 100644
--- package.json
+++ package.json
@@ -22,16 +22,18 @@
     "expo-camera": "~13.4.4",
     "expo-font": "~11.4.0",
     "expo-splash-screen": "~0.20.5",
+    "expo-status-bar": "~1.6.0",
     "react": "18.2.0",
     "react-native": "0.72.4",
     "react-native-paper": "^5.10.1",
     "react-native-safe-area-context": "4.6.3",
     "react-native-screens": "~3.22.0",
     "react-native-svg": "13.9.0",
+    "react-native-tab-view": "^3.5.2",
     "react-native-vector-icons": "^10.0.0",
     "react-native-webview": "13.2.2",
     "react-native-youtube-iframe": "^2.3.0",
-    "expo-status-bar": "~1.6.0"
+    "react-native-pager-view": "6.2.0"
   },
   "devDependencies": {
     "@babel/core": "^7.20.0",

One difference between a newly-created app and your app is as follows:

--- /tmp/cc-cup-2023/package.json	2023-09-15 12:34:40.504969179 +0200
+++ package.json	2023-09-15 12:55:06.379760340 +0200
@@ -4,8 +4,8 @@
   "main": "node_modules/expo/AppEntry.js",
   "scripts": {
     "start": "expo start",
-    "android": "expo start --android",
-    "ios": "expo start --ios",
+    "android": "expo run:android",
+    "ios": "expo run:ios",
     "web": "expo start --web"
   },
   "dependencies": {

This suggests to me that you have run npx expo prebuild or npx expo run:android which would have generated an android directory. It’s possible this is now out of sync.

If you do in fact have an android directory, but you have not made any manual changes under that, then I recommend you just delete it (and ios).

Another thing you can do is add android and ios to .gitignore so that they will not be uploaded to the EAS Build servers.

If you did make manual changes under android or ios, then I suggest you run npx expo prebuild --clean and redo those manual changes.

Hi @wodin

Thank you for your reply but I still seem to be getting the exact same error messages after making the appropriate changed. Could you please make a pull request to the repository so I can try it again. Also what profile did you build with?

I’ve also found out that builds with "developmentClient": true seem to work for me

Could you elaborate on exactly what you changed before trying to build again?

I built with the preview profile.

I’ve created a PR. Try cloning it again and see if it builds

@wodin I tried building after trying your version and it didn’t work on this account but it built perfectly fine on a new expo account. For now I’ll just use this new account to build my project. Thank you so much for the help!

It should not have anything to do with the account. The only possible way that comes to mind (but I don’t know if this is really possible) is if maybe you have some Expo secrets that the code makes use of in some way.

Did you try the following using the original Expo account?

  • Change to a blank directory
  • Clone the repository
  • cd temp_expo_post
  • npm install
  • eas build -p android --profile preview

Yeah that seems to be the root of the problem. My original folder was inside another project which already had a git repository

OK. Not entirely sure why that would be a problem, but glad you got it figured out