eas-cli CommandError "Ensure the metro.config.js file is extending 'expo/metro-config'"

60 views Asked by At

For some time now I have been doing updates with eas-cli and everything worked nicely until I have made the latest update to expo sdk v50

When I execute eas update --branch main, which I always did when I was doing updates with expo I get the following error:

[expo-cli] CommandError: The Metro bundler configuration is missing required features from 'expo/metro-config' and cannot be used with Expo CLI. Ensure the metro.config.js file is extending 'expo/metro-config'. Learn more: https://docs.expo.dev/guides/customizing-metro ✖ Export failed C:\Users\atana\Desktop\directory\directory\node_modules\expo\bin\cli exited with non-zero code: 1 Error: update command failed.

I have made changes in my metro.config.js from this:

    const { getDefaultConfig } = require("metro-config")
    const { getDefaultConfig: getDefaultExpoConfig } = require("@expo/metro-config")

    let metroConfig
    let isExpo = false
    try {
      const Constants = require("expo-constants")
      // True if the app is running in an `expo build` app or if it's running in Expo Go.
      isExpo =
        Constants.executionEnvironment === "standalone" ||
        Constants.executionEnvironment === "storeClient"
    } catch {}

    if (isExpo) {
      /**
       *  Expo metro config
       * Learn more https://docs.expo.io/guides/customizing-metro

       * For one idea on how to support symlinks in Expo, see:
       * https://github.com/infinitered/ignite/issues/1904#issuecomment-1054535068
       */
      metroConfig = getDefaultExpoConfig(__dirname)
    } else {
      /**
       * Vanilla metro config - we're using a custom metro config because we want to support symlinks
       * out of the box. This allows you to use pnpm and/or play better in a monorepo.
       *
       * You can safely delete this file and remove @rnx-kit/metro-* if you're not
       * using PNPM or monorepo or symlinks at all.
       *
       * However, it doesn't hurt to have it either.
       */
      const { makeMetroConfig } = require("@rnx-kit/metro-config")
      const MetroSymlinksResolver = require("@rnx-kit/metro-resolver-symlinks")

      metroConfig = (async () => {
        const defaultConfig = await getDefaultConfig()
        const {
          resolver: { sourceExts, assetExts }
        } = await getDefaultConfig();
        return makeMetroConfig({
          projectRoot: __dirname,
          // watchFolders: [`${__dirname}/../..`], // for monorepos
          transformer: {
            babelTransformerPath: require.resolve('react-native-svg-transformer'),
          },
          resolver: {
            /**
             * This custom resolver is for if you're using symlinks.
             *
             * You can disable it if you're not using pnpm or a monorepo or symlinks.
             */
            
            
            assetExts: assetExts.filter(ext => ext !== "svg"),
            sourceExts: [...sourceExts, "svg"]    
          },
          
        })
      })()
    }

    module.exports = metroConfig

to this:

    const { getDefaultConfig } = require("metro-config")
    const { getDefaultConfig: getDefaultExpoConfig } = require("@expo/metro-config")

    let metroConfig
    let isExpo = false
    try {
      const Constants = require("expo-constants")
      // True if the app is running in an `expo build` app or if it's running in Expo Go.
      isExpo =
        Constants.executionEnvironment === "standalone" ||
        Constants.executionEnvironment === "storeClient"
    } catch {}

    const config = getDefaultExpoConfig(__dirname)

    module.exports = config

And as you can see, I use expo/metro-config as suggested in the docs.

I changed the configuration because some assets were not loaded on iOS. But eas build command works perfectly with the new metro configuration and I can build and submit apps without issues and currently in production is the app with the new metro configuration.

If anyone have any suggestion how this can be solved, it will be appreciated.

0

There are 0 answers