TL;DR: Update your metro.config.js to use @expo/metro-config based on the latest guidelines (SDK 40+) –
It’s funny when you encounter an error in a project, and after spending a lot of effort researching it, to find out that the cause is the same with a totally different error on a very different project.
In my case this was caused by outdated metro.config.js
file, specifically the SVG loading code that uses react-native-svg-transformer
.
To fix it, I replaced the metro config with the following:
const { getDefaultConfig } = require("@expo/metro-config");
module.exports = (async () => {
const {
resolver: { sourceExts, assetExts }
} = await getDefaultConfig(__dirname);
return {
transformer: {
babelTransformerPath: require.resolve("react-native-svg-transformer")
},
resolver: {
assetExts: assetExts.filter(ext => ext !== "svg"),
sourceExts: [...sourceExts, "svg"]
}
};
})();
And also intall the '@expo/metro-config'
module:
yarn add @expo/metro-config
// or
npm install @expo/metro-config
More info on the other error – SVG Icons Not Loaded After Updating ReactNative Expo to Version 40
Cheers!