I was having a different reason. Documenting it for others below.
I started to get this error, the moment I added metro.config.js
to my app. I copied the contents from a tutorial as below:
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const {getDefaultConfig} = require('metro-config');
module.exports = async () => {
const {
resolver: {assetExts, sourceExts},
} = await getDefaultConfig();
return {
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};
};
But, I had to do the following changes to make it work:
- change the require path to
expo/metro-config
from just metro-config
- change the
getDefaultConfig()
call to getDefaultConfig(__dirname)
- extend existing configs, instead of overriding them
Here is the updated metro.config.js
that worked for me:
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const {getDefaultConfig} = require('expo/metro-config');
module.exports = async () => {
const defaultConfig = await getDefaultConfig(__dirname);
const {
resolver: {assetExts, sourceExts},
} = defaultConfig;
return {
...defaultConfig,
resolver: {
...defaultConfig.resolver,
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
transformer: {
...defaultConfig.transformer,
babelTransformerPath: require.resolve('react-native-svg-transformer'),
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};
};
Index.js
but importedindex.js
. Hello Case-sensitive-imports, my old friend. – Snout