最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - expo sdk 40 metro.config.js "Expected 'fromDir' to be 'string', got &#

programmeradmin5浏览0评论

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 :

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 
      resolverMainFields: ['native', 'module', 'browser', 'main'],
    },
  };
})();  

If you have any idea ?

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 :

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./facebook/metro/issues/485
      resolverMainFields: ['native', 'module', 'browser', 'main'],
    },
  };
})();  

If you have any idea ?

Share Improve this question asked Mar 29, 2021 at 19:42 E.DE.D 8913 gold badges17 silver badges35 bronze badges 4
  • Hey there E.D! How did you resolve this? Did you handle with that new library you've mentioned down here? – On the way to success Commented Sep 21, 2021 at 3:33
  • 1 @Onthewaytosuccess yes as I was able to indicate in the ment below ;) – E.D Commented Sep 21, 2021 at 13:22
  • Hey I got it solved somehow @E.D – On the way to success Commented Sep 27, 2021 at 6:36
  • Could you share the answer? @Onthewaytosuccess – Theo Oliveira Commented May 3, 2024 at 13:11
Add a ment  | 

1 Answer 1

Reset to default 17

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

It is required as per docs

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论