expo: Module not found: Can't resolve '@react-native/assets-registry/registry'
Minimal reproducible example
https://github.com/suchcodemuchwow/Expo-Error
Summary
Whenever I use:
import { FontAwesome } from “@expo/vector-icons”;
… <FontAwesome name="home" size={20} /> … This gives me an error of:
WARNING in ./node_modules/expo-asset/build/ReactNativeCompatibleAssetsRegistry.js:7:13
Module not found: Can't resolve '@react-native/assets-registry/registry'
5 | let registry: any | null = null;
6 | try {
> 7 | registry = require('@react-native/assets-registry/registry');
| ^
8 | } catch {}
9 | if (!registry) {
10 | try {
Environment
expo-env-info 1.0.5 environment info: System: OS: macOS 13.2.1 Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node npm: 9.4.2 - ~/.nvm/versions/node/v18.13.0/bin/npm IDEs: Xcode: /undefined - /usr/bin/xcodebuild npmPackages: @expo/webpack-config: ^18.0.1 => 18.0.1 expo: ~48.0.4 => 48.0.4 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.71.3 => 0.71.3 react-native-web: ~0.18.10 => 0.18.12 Expo Workflow: managed
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 10
- Comments: 30 (6 by maintainers)
Commits related to this issue
- [asset] revert @react-native/assets-registry compatible layer (#21559) # Why fix #21469 # How remove the `ReactNativeCompatibleAssetsRegistry` and import from `react-native/Libraries/Image/... — committed to expo/expo by Kudo a year ago
- [asset] revert @react-native/assets-registry compatible layer (#21559) # Why fix #21469 # How remove the `ReactNativeCompatibleAssetsRegistry` and import from `react-native/Libraries/Image/AssetR... — committed to expo/expo by Kudo a year ago
- fix: Remove Flow from @react-native/assets-registry's registry.js ## React native shipping Flow types breaks universal apps See: https://github.com/expo/expo/issues/21623#issuecomment-149218043... — committed to codinsonn/react-native by codinsonn 3 months ago
yarn add @react-native/assets-registryfixes the issue for me.I noticed the problems started after I upgraded to Expo 48.
A potential solution could involve using an earlier version of
expo-assetspecifically for web through package aliasing.Follow these steps to implement this fix:
package.jsonfile:Bear in mind, we’ll be employing distinct versions of
expo-assetfor web, iOS, and Android.webpack.config.jsfile and include the following content: (If thewebpack.config.jsfile is not located in the root directory of your project, please refer to these instructions to customize it: https://docs.expo.dev/guides/customizing-webpack/)rm -rf yarn.lock node_modulespostinstall.shfile and include the following content:package.jsonfile, find the scripts section, and add this script:This step is vital to ensure no conflict arises between
expo-assetandexpo-asset-webpackages when using Native modules in Android/iOS environments.package.jsonfile.yarn install --no-cache --ignore-platformyarn expo start --webNow, you should be able to launch your project on the web without encountering any issues.
We’re blocked by this as well. Upgraded to Expo 48, ran
yarn add @react-native/assets-registryto fix the original error and get the app working on web, but are now getting the same error as @codinsonn…In the CLI:
In our dev client:
This didn’t work for me unfortunately, but I think my issue is related to the combination of expo and next.js. Downgrading to expo 47, makes it work again with @expo/vector-icons.
Getting this as well after updating to 48
Thank you for filing this issue! This comment acknowledges we believe this may be a bug and there’s enough information to investigate it. However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.
You need to instruct whatever bundler you’re using to transpile
@react-native/assets-registry/registrysince the Facebook team ships that file untranspiled. In Next.js, you can do this with transpileModules.Trying to do the expo tutorial and running into this
This is a showstopper for us on upgrade to 48 as well!
I made it work by patching registry.js
thanks @danilovich 🎉
the
@react-native/assets-registrywill be a transitive package of react-native@0.72. (previously, it was@react-native/assets). i added that compatible code for 0.72 support and broke webpack unfortunately. so yeah, explicit@react-native/assets-registryor@react-native/assetsare not necessary.we’ve published
expo-asset@8.9.1with the fix. please try to upgrade this version and see whether it works for you. if you don’t have a direct dependency to expo-asset. please upgradeexpo@48.0.6(expo-asset is a transitive dependency of expo). thanks for waiting!Having the same issue as @codinsonn, but with the module
13, which cannot be found, after installing@react-native/assets/registry. In addition, the expo icons don’t show on web browserUncaught Error Module “13” is missing from the asset registry
node_modules/expo-asset/build/Asset.js (120:19)
I’m also experiencing issues that might be related to this.
Trying to use
@expo/vector-iconsin a next.js project.I follow the instructions here: https://docs.expo.dev/guides/using-nextjs/#font-support.
Whenever I try to load a font I get the above error, and the underlying error is this:
I’ve been trying to debug this for a while, but didn’t really get anywhere. Seems like an error for webpack parsing the flow syntax.
Update:
It works when downgrading to expo 47
What’s the Expo and RN version. Tried this but doesn’t work
@saeedblanchette yes I followed @Kudo 's advice and part of this issue as well https://github.com/facebook/react-native/issues/36343
@Kudo awesome! I’m happy to confirm that the issue is resolved now, thank you so much!
Also, it seems that with this update there is no need to install
@react-native/assets-registryexplicitly.We are experiencing the same issue as @giaset reported. Having expo sdk updated to expo@48.0.5, installed @react-native/assets-registry@0.72.0 and expo-font@11.1.1 Using the following code ` import { useFonts } from ‘expo-font’;
export const useCustomFonts = () => { const [fontsLoaded, error] = useFonts({ ‘FS Maja’: require(‘…/…/…/assets/maja/FSMaja-Regular.otf’), ‘FS Aldrin’: require(‘…/…/…/assets/aldrin/FSAldrin-Regular.ttf’), ‘FS Aldrin Medium’: require(‘…/…/…/assets/aldrin/FSAldrin-Medium.ttf’), ‘FS Aldrin Bold’: require(‘…/…/…/assets/aldrin/FSAldrin-Bold.ttf’), ‘FS Aldrin Light’: require(‘…/…/…/assets/aldrin/FSAldrin-Light.ttf’), ‘FS Aldrin Italic’: require(‘…/…/…/assets/aldrin/FSAldrin-Italic.ttf’), ‘equitec’: require(‘…/…/…/lib/module/ui/Icon/fonts/equitec.ttf’), });
console.log(error, fontsLoaded);
return { fontsLoaded, }; }; `
then the following error occurs
UPD: interesting that loading remote fonts is still working, so will use it as a temporary workaround to make app working.