eas-cli
eas-cli copied to clipboard
Type module (ESM) incompatible with EAS build
Build/Submit details page URL
https://expo.dev/accounts/loco/projects/bnm7d25/builds/0ba703f7-d5c2-4812-8ada-95874115e8a0
Summary
Build an app on EAS doesn't work if the project is setup to with "type": "module"
in the package.json
.
I think that this is because the EAS build checks if there is an metro.config.js
, and if there isn't it creates it itself. This however won't work with "type": "module"
since it will be treated as an esm file.
Locally this works for us since we have a metro.config.cjs
file. But it seems like EAS build creates metro.config.js
even when there is an metro.config.cjs
.
Workaround: our current workaround is to include a symlink from metro.config.js
to metro.config.cjs
. This allows the build to go thru...
Managed or bare?
Managed
Environment
expo-env-info 1.0.2 environment info:
System:
OS: macOS 13.3.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
Yarn: 1.22.19 - ~/coding/loco/order/node_modules/.bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
Watchman: 2023.05.01.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.12.0 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
IDEs:
Xcode: 14.3/14E222b - /usr/bin/xcodebuild
npmPackages:
expo: ^48.0.0 => 48.0.17
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.71.8 => 0.71.8
npmGlobalPackages:
expo-cli: 6.0.1
Expo Workflow: managed
✔ Validating global prerequisites versions passed
✔ Checking for incompatible packages passed
✔ Checking for conflicting global packages in project passed
✔ Verifying prebuild support package versions are compatible passed
✔ Checking dependency versions for compatibility with the installed Expo SDK passed
✔ Validating Expo Config passed
✔ Checking package.json for common issues passed
Didn't find any issues with the project!
Error output
Error: @build-script-error-begin
Error loading Metro config and Expo app config: require() of ES Module /Users/expo/workingdir/build/metro.config.js from /Users/expo/workingdir/build/node_modules/metro-config/node_modules/import-fresh/index.js not supported.
metro.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename metro.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/expo/workingdir/build/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
Make sure your project is configured properly and your app.json / app.config.js is valid.
If you are using environment variables in app.config.js, verify that you have set them in your EAS Build profile configuration or secrets.
@build-script-error-end
at /Users/expo/workingdir/build/node_modules/expo-updates/scripts/createManifest.js:52:11
Command PhaseScriptExecution failed with a nonzero exit code
Reproducible demo or steps to reproduce from a blank project
- Create a new blank project
- Add
"type": "module"
topackage.json
- Build on EAS
- ???
- :boo
Is this fixed?
Btw, app.config.ts plugins is somehow loaded with commonjs so adding "type": "module" messed that up as well and app.config.cjs and app.config.mjs aren't being recognized and I can only use app.config.ts.
Is there a workaround for that as well?
----- actually nvm, I found a solution, just need to rename those plugins files into .cjs
Is this fixed?
Btw, app.config.ts plugins is somehow loaded with commonjs so adding "type": "module" messed that up as well and app.config.cjs and app.config.mjs aren't being recognized and I can only use app.config.ts.
Is there a workaround for that as well?
----- actually nvm, I found a solution, just need to rename those plugins files into .cjs
how is it resolved?
Is this fixed?
Btw, app.config.ts plugins is somehow loaded with commonjs so adding "type": "module" messed that up as well and app.config.cjs and app.config.mjs aren't being recognized and I can only use app.config.ts.
Is there a workaround for that as well?
----- actually nvm, I found a solution, just need to rename those plugins files into .cjs
I'd very much like to know too, @pencilcheck :)
Experiencing this too