Working build on expo fails on EAS

Project Configuration:
Workflow: managed workflow
eas-cli version: eas-cli/0.46.0 linux-x64 node-v14.16.1
Command to reproduce the issue: eas build → select Android
Build url: Build Details — 6f1c4044-b50e-4e18-9478-0d14f0da973b — LocalChefs — Expo


Failure in Run gradlew phase
Notes:
(1)The project has been building successfully on expo for many versions.
(2) The project does not use idb-keyval module(the usage here is by the build process)


[stderr] error While trying to resolve module idb-keyval from file /root/workingdir/build/node_modules/parse/lib/react-native/IndexedDBStorageController.js, the package /root/workingdir/build/node_modules/idb-keyval/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/root/workingdir/build/node_modules/idb-keyval/dist/compat.cjs. Indeed, none of these files exist:

[stderr] * /root/workingdir/build/node_modules/idb-keyval/dist/compat.cjs(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

[stderr] * /root/workingdir/build/node_modules/idb-keyval/dist/compat.cjs/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx).

Error: While trying to resolve module idb-keyval from file /root/workingdir/build/node_modules/parse/lib/react-native/IndexedDBStorageController.js, the package /root/workingdir/build/node_modules/idb-keyval/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/root/workingdir/build/node_modules/idb-keyval/dist/compat.cjs. Indeed, none of these files exist:

  • /root/workingdir/build/node_modules/idb-keyval/dist/compat.cjs(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

  • /root/workingdir/build/node_modules/idb-keyval/dist/compat.cjs/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

    at DependencyGraph.resolveDependency (/root/workingdir/build/node_modules/metro/src/node-haste/DependencyGraph.js:436:17)

    at Object.resolve (/root/workingdir/build/node_modules/metro/src/lib/transformHelpers.js:317:42)

    at resolve (/root/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:629:33)

    at /root/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:645:26

    at Array.reduce ()

    at resolveDependencies (/root/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:644:33)

    at /root/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:329:33

    at Generator.next ()

    at asyncGeneratorStep (/root/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:24)

    at _next (/root/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:159:9)

info Run CLI with --verbose flag for more details.

Task :app:bundleReleaseJsAndAssets FAILED

[stderr] FAILURE: Build failed with an exception.

[stderr] * What went wrong:

[stderr] Execution failed for task ‘:app:bundleReleaseJsAndAssets’.

[stderr] > Process ‘command ‘node’’ finished with non-zero exit value 1

[stderr] * Try:

[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

[stderr] * Get more help at https://help.gradle.org

[stderr] BUILD FAILED in 3m 39s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

Use ‘–warning-mode all’ to show the individual deprecation warnings.

See Command-Line Interface

1 actionable task: 1 executed

Error: Gradle build failed with unknown error. Please see logs for the “Run gradlew” phase.

Are you using expo/yarn or npm?

I am using npm

I found that I often get build errors when I’ve been installing packages using npm.

Try to delete your package-lock.json, and reinstall all your packages with expo install

There might be some errors when you run your app again, but if you fix those the build will probably work. Worth a shot.

@shuggs Thanks. Just tried that. The same error during the gradlew phase.

Not sure then looks like it’s a problem with idb-keyval

1 Like

idb-keyval appears to use cjs for the main export, which is not supported out of the box by metro. idb-keyval/package.json at fdf795b9b55b417eb6ed22db9721c53877a19569 · jakearchibald/idb-keyval · GitHub

you may be able to work around this by moving back to version 5 of that package: idb-keyval/package.json at c32802803d422f03462ace8e108fc5ea1a2106f7 · jakearchibald/idb-keyval · GitHub

Not sure I follow. My project does not use idb-keyval. How would I move back to version 5 of it? My impression, looking at the log, is that the build system is using it. Not true?

it does. some library you are using is depending on it. look in your lockfile. it looks like it’s parse:

Error: While trying to resolve module `idb-keyval` from file `/root/workingdir/build/node_modules/parse/lib/react-native/IndexedDBStorageController.js`, the package `/root/workingdir/build/node_modules/idb-keyval/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/root/workingdir/build/node_modules/idb-keyval/dist/compat.cjs

here’s the related issue on the parse repo: React native SDK error: While trying to resolve module `idb-keyval` from file · Issue #1441 · parse-community/Parse-SDK-JS · GitHub

Thanks. You were right. Build now works fine after changing parse version.