expo sdk 40 metro.config.js "Expected 'fromDir' to be 'string', got 'undefined' "

Viewed 1980

I’m on a monorepo with yarn workspace and I’m also using react-native-svg-transformer. I have updated the sdk to the sdk 40 and I have this error in the metro.config.js : enter image description here

and there is my metro.config.js :

const { createMetroConfiguration } = require('expo-yarn-workspaces');
const { getDefaultConfig } = require('@expo/metro-config');
const configuration = createMetroConfiguration(__dirname);
module.exports = (async () => {
  const {
    resolver: { sourceExts },
  } = await getDefaultConfig();
  return {
    transformer: {
      babelTransformerPath: require.resolve('react-native-svg-transformer'),
    },
    resolver: {
      ...configuration.resolver,
      assetExts: configuration.resolver.assetExts.filter(ext => ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg'],
      // NOTE: using native entrypoint because bug in metro https://github.com/facebook/metro/issues/485
      resolverMainFields: ['native', 'module', 'browser', 'main'],
    },
  };
})();  

If you have any idea ?

1 Answers

Add the __dirname param in await getDefaultConfig() so it should be await getDefaultConfig(__dirname)

It is required as per docs

Related