expo / eas-cli

Fastest way to build, submit, and update iOS and Android apps
https://docs.expo.dev/eas/
MIT License
845 stars 85 forks source link

Build failed: "Error: Cannot find module '../lightningcss.linux-x64-gnu.node'" #2727

Open SoheilY opened 4 days ago

SoheilY commented 4 days ago

Build/Submit details page URL

https://expo.dev/accounts/soheilxpawn/projects/german-term-new-arch/builds/5647d5e9-5f71-4327-93d8-034e78f1a281

Summary

I want to build an APK of my app for android with "eas build -p android --profile preview" command but in EAS I get error in bundle javascript step:

Error: Cannot find module '../lightningcss.linux-x64-gnu.node'

I don't get this error using "npx expo run:android" command and app works without any errors in android emulator.

Managed or bare?

Bare

Environment

npx expo-env-info:

expo-env-info 1.2.1 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 20.14.0 - C:\Program Files\nodejs\node.EXE
      npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
    SDKs:
      Android SDK:
        API Levels: 31, 34, 35
        Build Tools: 30.0.3, 34.0.0, 35.0.0
        System Images: android-35 | Google APIs Intel x86_64 Atom, android-35 | Google Play Intel x86_64 Atom
    npmPackages:
      expo: ~52.0.11 => 52.0.11 
      expo-router: ~4.0.9 => 4.0.9 
      react: 18.3.1 => 18.3.1 
      react-dom: 18.3.1 => 18.3.1 
      react-native: 0.76.3 => 0.76.3 
      react-native-web: ~0.19.13 => 0.19.13 
    Expo Workflow: bare

npx expo-doctor:

WARNING: We recommend using PowerShell or Bash via WSL 2 for development with Expo CLI on Windows. You may encounter issues using cmd.exe.

Enabled experimental React Native Directory checks. Unset the EXPO_DOCTOR_ENABLE_DIRECTORY_CHECK environment variable to disable this check.
✔ Check package.json for common issues
✔ Check Expo config for common issues
✔ Check native tooling versions
✔ Check for common project setup issues
✔ Check dependencies for packages that should not be installed directly
✔ Check npm/ yarn versions
✔ Check for issues with Metro config
✔ Check for legacy global CLI installed locally
✔ Check that native modules do not use incompatible support packages
✖ Check for app config fields that may not be synced in a non-CNG project
✔ Check if the project meets version requirements for submission to app stores
✖ Validate packages against React Native Directory package metadata
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check that packages match versions required by installed Expo SDK
✔ Check that native modules use compatible support package versions for installed Expo SDK

Detailed check results:

This project contains native project folders but also has native configuration properties in app.json, indicating it is configured to use Prebuild. When the android/ios folders are present, EAS Build will not sync the following properties: orientation, icon, scheme, userInterfaceStyle, ios, android, plugins, androidStatusBar.

Advice: Add '/android' and '/ios' to your .gitignore file if you intend to use CNG / Prebuild. Learn more: https://docs.expo.dev/workflow/prebuild/#usage-with-eas-build

The following issues were found when validating your dependencies against React Native Directory:
Untested on New Architecture: lucide-react-native
No metadata available: @rn-primitives/aspect-ratio, @rn-primitives/dialog, @rn-primitives/portal, class-variance-authority, tailwindcss, tailwindcss-animate
Advice:
- Use libraries that are actively maintained and support the New Architecture. Find alternative libraries with https://reactnative.directory.
- Add packages to expo.doctor.reactNativeDirectoryCheck.exclude in package.json to selectively skip validations, if the warning is not relevant.
- Update React Native Directory to include metadata for unknown packages. Alternatively, set expo.doctor.reactNativeDirectoryCheck.listUnknownPackages in package.json to false to skip warnings about packages with no metadata, if the warning is not relevant.

One or more checks failed, indicating possible issues with the project.

Error output

No response

Reproducible demo or steps to reproduce from a blank project

eas.json:

{
  "cli": {
    "version": ">= 13.4.1",
    "appVersionSource": "remote"
  },
  "build": {
    "preview": {
      "android": {
        "buildType": "apk"
      }
    },
    "preview2": {
      "android": {
        "gradleCommand": ":app:assembleRelease"
      }
    },
    "preview3": {
      "developmentClient": true
    },
    "preview4": {
      "distribution": "internal"
    },
    "production": {}
  },
  "submit": {
    "production": {}
  }
}

package.json:

{
  "name": "german-term-new-arch",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "test": "jest --watchAll",
    "lint": "expo lint"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^14.0.2",
    "@gorhom/bottom-sheet": "^5.0.6",
    "@react-navigation/bottom-tabs": "^7.0.0",
    "@react-navigation/native": "^7.0.0",
    "@react-navigation/stack": "^7.0.4",
    "@rn-primitives/aspect-ratio": "^1.1.0",
    "@rn-primitives/dialog": "^1.1.0",
    "@rn-primitives/portal": "^1.1.0",
    "@shopify/flash-list": "1.7.1",
    "@tanstack/react-query": "^5.60.6",
    "axios": "^1.7.7",
    "class-variance-authority": "^0.7.0",
    "expo": "~52.0.11",
    "expo-blur": "~14.0.1",
    "expo-constants": "~17.0.3",
    "expo-font": "~13.0.1",
    "expo-haptics": "~14.0.0",
    "expo-image": "~2.0.2",
    "expo-jwt": "^1.8.0",
    "expo-linking": "~7.0.3",
    "expo-localization": "~16.0.0",
    "expo-navigation-bar": "~4.0.4",
    "expo-router": "~4.0.9",
    "expo-splash-screen": "~0.29.13",
    "expo-status-bar": "~2.0.0",
    "expo-symbols": "~0.2.0",
    "expo-system-ui": "~4.0.4",
    "expo-web-browser": "~14.0.1",
    "lucide-react-native": "^0.460.0",
    "nativewind": "^4.1.23",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-hook-form": "^7.53.2",
    "react-native": "0.76.3",
    "react-native-gesture-handler": "~2.20.2",
    "react-native-keyboard-controller": "^1.14.5",
    "react-native-mmkv": "^3.1.0",
    "react-native-otp-entry": "^1.7.3",
    "react-native-reanimated": "~3.16.1",
    "react-native-safe-area-context": "4.12.0",
    "react-native-screens": "^4.0.0",
    "react-native-svg": "15.8.0",
    "react-native-web": "~0.19.13",
    "react-native-webview": "13.12.2",
    "sonner-native": "^0.16.0",
    "tailwind-merge": "^2.5.4",
    "tailwindcss": "^3.4.15",
    "tailwindcss-animate": "^1.0.7",
    "zustand": "^5.0.1",
    "expo-asset": "~11.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@types/jest": "^29.5.12",
    "@types/react": "~18.3.12",
    "@types/react-test-renderer": "^18.3.0",
    "jest": "^29.2.1",
    "jest-expo": "~52.0.2",
    "react-test-renderer": "18.3.1",
    "typescript": "^5.3.3"
  },
  "private": true
}

metro.config.js:

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
const { withNativeWind } = require('nativewind/metro');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

module.exports = withNativeWind(config, { input: './styles/global.css' });
szdziedzic commented 4 days ago

What happens if you run npx expo export:embed --eager --platform android --dev false locally?

SoheilY commented 4 days ago

What happens if you run npx expo export:embed --eager --platform android --dev false locally?

$ npx expo export:embed --eager --platform android --dev false
Starting Metro Bundler
Error: Unable to resolve module ./D:/Projects/german-term-new-arch/node_modules/expo-router/entry.js from D:\Projects\german-term-new-arch/.: 

None of these files exist:
  * D:\Projects\german-term-new-arch\node_modules\expo-router\entry.js(.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.mjs|.native.mjs|.mjs|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.css|.native.css|.css|.android.css|.native.css|.css)
  * D:\Projects\german-term-new-arch\node_modules\expo-router\entry.js
Error: Unable to resolve module ./D:/Projects/german-term-new-arch/node_modules/expo-router/entry.js from D:\Projects\german-term-new-arch/.: 

None of these files exist:
  * D:\Projects\german-term-new-arch\node_modules\expo-router\entry.js(.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.mjs|.native.mjs|.mjs|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.css|.native.css|.css|.android.css|.native.css|.css)
  * D:\Projects\german-term-new-arch\node_modules\expo-router\entry.js
    at ModuleResolver.resolveDependency (D:\Projects\german-term-new-arch\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:112:15)
    at DependencyGraph.resolveDependency (D:\Projects\german-term-new-arch\node_modules\metro\src\node-haste\DependencyGraph.js:235:43)
    at D:\Projects\german-term-new-arch\node_modules\metro\src\lib\transformHelpers.js:160:21
    at Server._resolveRelativePath (D:\Projects\german-term-new-arch\node_modules\metro\src\Server.js:1104:12)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at MetroBundlerDevServer.resolveRelativePathAsync (D:\Projects\german-term-new-arch\node_modules\@expo\cli\src\start\server\metro\MetroBundlerDevServer.ts:1677:12)
    at MetroBundlerDevServer.metroLoadModuleContents (D:\Projects\german-term-new-arch\node_modules\@expo\cli\src\start\server\metro\MetroBundlerDevServer.ts:506:35)
    at MetroBundlerDevServer.legacySinglePageExportBundleAsync (D:\Projects\german-term-new-arch\node_modules\@expo\cli\src\start\server\metro\MetroBundlerDevServer.ts:809:20)
    at exportEmbedBundleAndAssetsAsync (D:\Projects\german-term-new-arch\node_modules\@expo\cli\src\export\embed\exportEmbedAsync.ts:193:21)
    at exportEmbedInternalAsync (D:\Projects\german-term-new-arch\node_modules\@expo\cli\src\export\embed\exportEmbedAsync.ts:125:37)

I checked the mentioned path and entry.js file exists despite the error.

szdziedzic commented 4 days ago

It doesn't seem to work too well on Windows 😅. I will let Expo CLI folks know about it.

Do you use CNG? If so it would be good to add the ./android'and ./ios directories to your .gitignore file so we run a clean prebuild during the build process. I believe it can help with this issue because the prebuild will be run on Linux then.

SoheilY commented 3 days ago

It doesn't seem to work too well on Windows 😅. I will let Expo CLI folks know about it.

Thanks!

Do you use CNG? If so it would be good to add the ./android'and ./ios directories to your .gitignore file so we run a clean prebuild during the build process. I believe it can help with this issue because the prebuild will be run on Linux then.

I tried adding ./android'and ./ios to .gitignore and it still didn't work.

I made a copy of project again, deleted everything related to nativewind and no longer got the error. It seems nativewind requires lightningcss and I guess it is related to cssInterop function.

Although as a workaround to building without removing nativewind, I added lightningcss-linux-x64-gnu as a dev dependency to my package.json and removed package-lock.json file before running eas build -p android --profile preview command and build was successful.