facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.24k stars 626 forks source link

Unable to resolve module missing-asset-registry-path #1368

Open A-Kasaaian opened 1 month ago

A-Kasaaian commented 1 month ago

Do you want to request a feature or report a bug? bug

What is the current behavior? I see following error when I build production bundle

Error: Unable to resolve module missing-asset-registry-path from /Users/XXX/Develop/XXX/node_modules/@react-navigation/elements/lib/commonjs/assets/back-icon-mask.png: missing-asset-registry-path could not be found within the project or in these directories:
  node_modules/@react-navigation/elements/node_modules
  node_modules
> 1 | �PNG
  2 | 
  3 | 
  4 | IHDR2���gAMA��
                    �a cHRMz&�����u0�`:�p��Q<bKGD���̿tIME�
  2 | 
  3 | 
  4 | IHDR2���gAMA��
                    �a cHRMz&�����u0�`:�p��Q<bKGD���̿tIME�.

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test. on react native project cd android && ./gradlew bundleRelease

What is the expected behavior? Metro should process images

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

const config = { };

module.exports = mergeConfig(getDefaultConfig(__dirname), config)

I have already tried most of configs shared on this repo and react-native repo or stackoverflow.

robhogan commented 1 month ago

Hi @A-Kasaaian, you don't mention what versions of RN/Metro/(Expo?) you're using, which might be helpful, but that looks like your configuration isn't being picked up at all - ie the CLI isn't finding your config file.

What's your project structure and what's the name and location of your config file?

A-Kasaaian commented 1 month ago

All was working on RN 70.6 but I had to upgrade packages. I ended up with current latest versions of metro and RN (75.4).

I had the same error for my project images but I resolved them by changing Image attribute source ={require('@assets/image.png')} to source={{ uri: '@assets/image.png'}}.

robhogan commented 1 month ago

I'm not sure whether you're saying this can be closed?

If not could you describe your project structure and Metro config path?