Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Can't resolve '@react-native/assets-registry/registry' #21469

Closed
suchcodemuchwow opened this issue Mar 1, 2023 · 48 comments · Fixed by #21559
Closed

Module not found: Can't resolve '@react-native/assets-registry/registry' #21469

suchcodemuchwow opened this issue Mar 1, 2023 · 48 comments · Fixed by #21559
Assignees

Comments

@suchcodemuchwow
Copy link

suchcodemuchwow commented Mar 1, 2023

Minimal reproducible example

https://github.com/suchcodemuchwow/Expo-Error

Summary

Whenever I use:

import { FontAwesome } from "@expo/vector-icons";

...

...
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

@suchcodemuchwow suchcodemuchwow added the needs validation Issue needs to be validated label Mar 1, 2023
@expo-bot expo-bot added the needs review Issue is ready to be reviewed by a maintainer label Mar 1, 2023
@CruelMoney
Copy link

CruelMoney commented Mar 2, 2023

I'm also experiencing issues that might be related to this.

Trying to use @expo/vector-icons in 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:

error - ../node_modules/@react-native/assets/registry.js
Error: 
  x Expected '{', got 'type'
    ,-[/PROJECTFOLDER/node_modules/@react-native/assets/registry.js:10:1]
 10 | 
 11 | 'use strict';
 12 | 
 13 | export type PackagerAsset = {
    :        ^^^^
 14 |   +__packager_asset: boolean,
 15 |   +fileSystemLocation: string,
 16 |   +httpServerLocation: string,
    `----

Caused by:
    Syntax Error

Import trace for requested module:
../node_modules/@react-native/assets/registry.js
../node_modules/expo-asset/build/ReactNativeCompatibleAssetsRegistry.js
../node_modules/expo-asset/build/Asset.js
../node_modules/expo-asset/build/index.js
../node_modules/expo-font/build/FontLoader.web.js
../node_modules/expo-font/build/Font.js
../node_modules/expo-font/build/index.js
../node_modules/@expo/vector-icons/build/createIconSet.js
../node_modules/@expo/vector-icons/build/Icons.js

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

@Kudo Kudo added Issue accepted and removed needs validation Issue needs to be validated needs review Issue is ready to be reviewed by a maintainer labels Mar 2, 2023
@Kudo Kudo self-assigned this Mar 2, 2023
@expo-bot
Copy link
Collaborator

expo-bot commented Mar 2, 2023

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.

@kjkurtz
Copy link

kjkurtz commented Mar 3, 2023

This is a showstopper for us on upgrade to 48 as well!

@philsmithies
Copy link

Trying to do the expo tutorial and running into this

@hdwatts
Copy link
Contributor

hdwatts commented Mar 5, 2023

Getting this as well after updating to 48

@mstorick
Copy link

mstorick commented Mar 6, 2023

yarn add @react-native/assets-registry fixes the issue for me.

@ThisIsSimple
Copy link

yarn add @react-native/assets-registry fixes the issue for me.

This solved my issue too! Thanks

@CruelMoney
Copy link

CruelMoney commented Mar 6, 2023

yarn add @react-native/assets-registry fixes the issue for me.

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.

@codinsonn
Copy link
Contributor

codinsonn commented Mar 6, 2023

Having the same issue as @CruelMoney, installing @react-native/assets-registry fixes the issue for web with Next.js, but then breaks my builds on Expo again (SDK 48), stating that the module 12 (a roboto font from expo-google-fonts) cannot be found.

Likely related to #20258

@francolivelli
Copy link

francolivelli commented Mar 6, 2023

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 browser

Uncaught Error
Module "13" is missing from the asset registry

node_modules/expo-asset/build/Asset.js (120:19)

   118 | const meta = getAssetByID(virtualAssetModule);
   119 | if (!meta) {
> 120 |   throw  new Error(`Module "${virtualAssetModule}" is missing from the asset registry`); 
          |              ^
   121 |}
   122 |// Outside of the managed env we need the moduleId to initialize the asset
   123 |// because resolveAssetSource depends on it

@giaset
Copy link

giaset commented Mar 6, 2023

We're blocked by this as well. Upgraded to Expo 48, ran yarn add @react-native/assets-registry to fix the original error and get the app working on web, but are now getting the same error as @codinsonn...

In the CLI:

Error: Module "7" is missing from the asset registry

In our dev client:

Unrecognized font family 'Montserrat_500Medium'

Kudo added a commit that referenced this issue Mar 8, 2023
# Why

fix #21469

# How

remove the `ReactNativeCompatibleAssetsRegistry` and import from `react-native/Libraries/Image/AssetRegistry`
 
# Test Plan

- ci passed
- `npx expo export:web`
@danilovich
Copy link

danilovich commented Mar 8, 2023

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

image

UPD: interesting that loading remote fonts is still working, so will use it as a temporary workaround to make app working.

Kudo added a commit that referenced this issue Mar 8, 2023
# Why

fix #21469

# How

remove the `ReactNativeCompatibleAssetsRegistry` and import from `react-native/Libraries/Image/AssetRegistry`

# Test Plan

- ci passed
- `npx expo export:web`

(cherry picked from commit 966e36f)
@Kudo
Copy link
Contributor

Kudo commented Mar 8, 2023

we've published expo-asset@8.9.1 with 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 upgrade expo@48.0.6 (expo-asset is a transitive dependency of expo). thanks for waiting!

@danilovich
Copy link

@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-registry explicitly.

@Kudo
Copy link
Contributor

Kudo commented Mar 8, 2023

thanks @danilovich 🎉

the @react-native/assets-registry will 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-registry or @react-native/assets are not necessary.

@CruelMoney
Copy link

@Kudo Thanks for the work 🙏

Just attempted to upgrade both expo-asset and expo itself, but the error previously mentioned is still there.

I think it's probably a different issue than mentioned here, but it still seems related to assets-registry and expo 48.

It's a bit of a complex project with next.js and using @expo/next-adapter. The error comes from next.js.

Working on an example repo to reproduce the error.

@Philip-Smyth
Copy link

Philip-Smyth commented Mar 8, 2023

Hi there @Kudo 👋
I was wondering if there is any progress on resolving this issue?

Out of curiosity I created a fresh project, however it still seems to occur.

Relevant package versions:

"expo": "~48.0.6",
"expo-asset": "~8.9.1",

Any advice is appreciated 😄

@peedrogaabriiel
Copy link

yarn add @react-native/assets-registry fixes the issue for me.

Muito obrigado, isso resolveu meu problema de modo rápido, nota 10!

@saeedblanchette
Copy link

saeedblanchette commented Apr 8, 2023

@Jonatthu @anirudhsama did you fix the issue you mentioned cuz I have it too

@Kudo Is this even related?

error - ../../node_modules/@react-native/assets/registry.js Error: x Expected '{', got 'type' ,-[/Users/jonatthu/DatterX/datterx-buildkit/products/datterx-aix/node_modules/@react-native/assets/registry.js:10:1] 10 | 11 | 'use strict'; 12 | 13 | export type PackagerAsset = { : ^^^^ 14 | +__packager_asset: boolean, 15 | +fileSystemLocation: string, 16 | +httpServerLocation: string, `----

Caused by: Syntax Error

Import trace for requested module: ../../node_modules/@react-native/assets/registry.js ../../node_modules/react-native/Libraries/Image/AssetRegistry.js ../../node_modules/expo-asset/build/Asset.js ../../node_modules/expo-asset/build/index.js ../../node_modules/expo-font/build/FontLoader.web.js ../../node_modules/expo-font/build/Font.js ../../node_modules/expo-font/build/index.js ../../node_modules/@expo/vector-icons/build/createIconSet.js ../../node_modules/@expo/vector-icons/build/Icons.js

@Jonatthu
Copy link

Jonatthu commented Apr 8, 2023

@saeedblanchette yes I followed @Kudo 's advice and part of this issue as well facebook/react-native#36343

@saeedblanchette
Copy link

saeedblanchette commented Apr 9, 2023

@Jonatthu thank you for your feedback, I've followed @kudie 's advice, and I have added explicitly packages to transpilePackages in next.config.js but still, I have the same error, did I miss any other steps?

@anirudhsama
Copy link
Contributor

I made it work by patching registry.js

diff --git a/node_modules/@react-native/assets/registry.js b/node_modules/@react-native/assets/registry.js
index 088187f..0a384d1 100644
--- a/node_modules/@react-native/assets/registry.js
+++ b/node_modules/@react-native/assets/registry.js
@@ -10,28 +10,16 @@
 
 'use strict';
  
-export type PackagerAsset = {
-  +__packager_asset: boolean,
-  +fileSystemLocation: string,
-  +httpServerLocation: string,
-  +width: ?number,
-  +height: ?number,
-  +scales: Array<number>,
-  +hash: string,
-  +name: string,
-  +type: string,
-  ...
-};
 
-const assets: Array<PackagerAsset> = [];
+const assets = [];
 
-function registerAsset(asset: PackagerAsset): number {
+function registerAsset(asset) {
   // `push` returns new array length, so the first asset will
   // get id 1 (not 0) to make the value truthy
   return assets.push(asset);
 }
 
-function getAssetByID(assetId: number): PackagerAsset {
+function getAssetByID(assetId) {
   return assets[assetId - 1];
 }

@xinha-sh
Copy link

[asset] revert @react-native/assets-registry compatible layer #21559

What's the Expo and RN version. Tried this but doesn't work

@Yorkshireman
Copy link

#21469 (comment)

I'm getting a similar problem (Error: Module "1" is missing from the asset registry) when running my jest tests

@agostinhodev
Copy link

I noticed the problems started after I upgraded to Expo 48.

A potential solution could involve using an earlier version of expo-asset specifically for web through package aliasing.

Follow these steps to implement this fix:

  1. Incorporate the following lines into your dependencies at package.json file:
"expo-asset": "^8.9.1",
"expo-asset-web": "npm:expo-asset@8.7.0"

Bear in mind, we'll be employing distinct versions of expo-asset for web, iOS, and Android.

  1. Open your webpack.config.js file and include the following content: (If the webpack.config.js file 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/)
const createExpoWebpackConfigAsync = require('@expo/webpack-config');

module.exports = async function (env, argv) {
    const config = await createExpoWebpackConfigAsync(env, argv);
    // Insert the following code snippet: 👇
    config.resolve.alias['expo-asset'] = 'expo-asset-web';
    // Rest of your code...
    return config;
};
  1. Execute the command: rm -rf yarn.lock node_modules
  2. In the root directory of your project, create a postinstall.sh file and include the following content:
#!/bin/sh
rm -rf node_modules/expo-asset-web/node_modules/@expo/config-plugins/build
  1. Return to your package.json file, find the scripts section, and add this script:
"postinstall": "chmod +x ./postinstall.sh && ./postinstall.sh"

This step is vital to ensure no conflict arises between expo-asset and expo-asset-web packages when using Native modules in Android/iOS environments.

  1. Save and close your package.json file.
  2. Run: yarn install --no-cache --ignore-platform
  3. Run: yarn expo start --web

Now, you should be able to launch your project on the web without encountering any issues.

@EvanBacon
Copy link
Contributor

You need to instruct whatever bundler you're using to transpile @react-native/assets-registry/registry since the Facebook team ships that file untranspiled. In Next.js, you can do this with transpileModules.

@powerpufffs
Copy link

powerpufffs commented Jan 6, 2024

Patching @react-native/assets-registry worked for me!

Cred to @nandorojo #21623 (comment)

Summary

  • registry.js contains Flow (aka Facebook's version of typescript)
  • you need to remove all of the type related code in the file so it ships pure js

Steps:

yarn patch-package @react-native/assets-registry --use-yarn

// follow https://github.com/expo/expo/issues/21623#issuecomment-1492180436 to patch

yarn patch-commit -s PATH_TO_PATCH_FILE

@EmePin
Copy link

EmePin commented May 11, 2024

I have this in sdk 51

WARNING in ./node_modules/expo-asset/build/Asset.fx.js:6:4
export 'IS_ENV_WITH_LOCAL_ASSETS' (imported as 'IS_ENV_WITH_LOCAL_ASSETS') was not found in './PlatformUtils' (possible exports: IS_ENV_WITH_UPDATES_ENABLED, getManifest, getManifest2, manifest 4 |
4 |
5 | // Override React Native's asset resolution for Image components in contexts where it matters

6 | if (IS_ENV_WITH_LOCAL_ASSETS) {
| ^
7 | setCustomSourceTransformer((resolver) => {
8 | try {
9 | // Bundler is using the hashAssetFiles plugin if and only if the fileHashes property exists

WARNING in ./node_modules/expo-asset/build/Asset.js:149:9
export 'IS_ENV_WITH_LOCAL_ASSETS' (imported as 'IS_ENV_WITH_LOCAL_ASSETS') was not found in './PlatformUtils' (possible exports: IS_ENV_WITH_UPDATES_ENABLED, getManifest, getManifest2, manifestBaseUrl)
147 | // Outside of the managed env we need the moduleId to initialize the asset
148 | // because resolveAssetSource depends on it

149 | if (!IS_ENV_WITH_LOCAL_ASSETS) {
| ^
150 | // null-check is performed above with getAssetByID.
151 | const { uri } = resolveAssetSource(virtualAssetModule)!;
152 |
ERROR in ./node_modules/expo-modules-core/build/uuid/uuid.web.js:9:8
Module not found: Can't resolve 'crypto'
7 | const cryptoObject =
8 | typeof crypto === 'undefined' || typeof crypto.randomUUID === 'undefined'
9 | ? require('crypto')
| ^
10 | : crypto;
11 |
12 | if (!cryptoObject?.randomUUID) {

web compiled with 1 error and 2 warnings

@abdulsamadayoade
Copy link

I have this in sdk 51

WARNING in ./node_modules/expo-asset/build/Asset.fx.js:6:4 export 'IS_ENV_WITH_LOCAL_ASSETS' (imported as 'IS_ENV_WITH_LOCAL_ASSETS') was not found in './PlatformUtils' (possible exports: IS_ENV_WITH_UPDATES_ENABLED, getManifest, getManifest2, manifest 4 | 4 | 5 | // Override React Native's asset resolution for Image components in contexts where it matters

6 | if (IS_ENV_WITH_LOCAL_ASSETS) {
| ^
7 | setCustomSourceTransformer((resolver) => {
8 | try {
9 | // Bundler is using the hashAssetFiles plugin if and only if the fileHashes property exists

WARNING in ./node_modules/expo-asset/build/Asset.js:149:9 export 'IS_ENV_WITH_LOCAL_ASSETS' (imported as 'IS_ENV_WITH_LOCAL_ASSETS') was not found in './PlatformUtils' (possible exports: IS_ENV_WITH_UPDATES_ENABLED, getManifest, getManifest2, manifestBaseUrl) 147 | // Outside of the managed env we need the moduleId to initialize the asset 148 | // because resolveAssetSource depends on it

149 | if (!IS_ENV_WITH_LOCAL_ASSETS) {
| ^
150 | // null-check is performed above with getAssetByID.
151 | const { uri } = resolveAssetSource(virtualAssetModule)!;
152 |
ERROR in ./node_modules/expo-modules-core/build/uuid/uuid.web.js:9:8
Module not found: Can't resolve 'crypto'
7 | const cryptoObject =
8 | typeof crypto === 'undefined' || typeof crypto.randomUUID === 'undefined'
9 | ? require('crypto')
| ^
10 | : crypto;
11 |
12 | if (!cryptoObject?.randomUUID) {

web compiled with 1 error and 2 warnings

I'm having the same issue too

@denisgoksel
Copy link

Hi friends, i have same the problem as you, so solution is that for me,

npm i @react-native/assets-registry

try this code command line.

@Diegow3b
Copy link

Diegow3b commented Jun 4, 2024

Im having the same issue with IS_ENV_WITH_LOCAL_ASSETS

Also the @denisgoksel didn't work for me.

@giaset
Copy link

giaset commented Jun 4, 2024

Also getting this same warning on web export 'IS_ENV_WITH_LOCAL_ASSETS' (imported as 'IS_ENV_WITH_LOCAL_ASSETS') was not found in './PlatformUtils'

@mahesh123pandav
Copy link

Im having the same issue with IS_ENV_WITH_LOCAL_ASSETS

@denisgoksel
Copy link

Im having the same issue with IS_ENV_WITH_LOCAL_ASSETS

Also the @denisgoksel didn't work for me.

it worked for me,,

npm i @react-native/assets-registry

yarn version;
yarn add @react-native/assets-registry

write this code to your command line.

and my package.json like below, check it.

{
"name": "dortproj",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"@expo/vector-icons": "^13.0.0",
"@react-native/assets-registry": "^0.74.83",
"expo": "^51.0.8",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.10",
"react-native-uuid": "^2.0.2",
"react-native-vector-icons": "^10.1.0",
"uuid": "^9.0.1"
},
"devDependencies": {
"@babel/core": "^7.20.0"
},
"private": true
}

@LRiceCooker
Copy link

Im having the same issue with IS_ENV_WITH_LOCAL_ASSETS

Also the @denisgoksel didn't work for me.

Same, @denisgoksel 's solution doesn't work for me either. I have a project that uses solito & tamagui and this error occurred while installing the expo-av package. Patching the @react-native/assets-registry package fixed the first problem. But regarding this error: export 'IS_ENV_WITH_LOCAL_ASSETS' (imported as 'IS_ENV_WITH_LOCAL_ASSETS') was not found in './PlatformUtils, installing the package (via yarn add @react-native/assets-registry or npm i @react- native/assets-registry) no matter where in the monorepo (root included) does not solve the problem for me. Is there a specific order between patching the package and reinstalling it?

@Hardeygold205
Copy link

Im same issue. Im trying to make my fonts and images loaded while on the splashscreen.

ERROR Error loading resources: [Error: Module "9" is missing from the asset registry]

//app.json

"plugins": [
"expo-dev-client",
"expo-font",
"expo-asset"
]

//packet.json

"dependencies": {
"@expo-google-fonts/alfa-slab-one": "^0.2.3",
"@expo-google-fonts/inter": "^0.2.3",
"@expo-google-fonts/poppins": "^0.2.3",
"@expo-google-fonts/roboto": "^0.2.3",
"@expo-google-fonts/roboto-mono": "^0.2.3",
"@expo/metro-runtime": "~3.2.1",
"@react-native-async-storage/async-storage": "^1.23.1",
"@react-navigation/bottom-tabs": "^6.5.20",
"@react-navigation/material-bottom-tabs": "^6.2.28",
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.9.26",
"axios": "^1.7.2",
"expo": "^51.0.9",
"expo-app-loading": "^2.1.1",
"expo-dev-client": "~4.0.15",
"expo-font": "~12.0.7",
"expo-status-bar": "~1.12.1",
"jest": "^29.7.0",
"nativewind": "^2.0.11",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.1",
"react-native-navigation": "^7.39.2",
"react-native-onboarding-swiper": "^1.2.0",
"react-native-paper": "^5.12.3",
"react-native-reanimated": "^3.10.1",
"react-native-responsive-fontsize": "^0.5.1",
"react-native-safe-area-context": "^4.10.1",
"react-native-screens": "^3.31.1",
"react-native-swiper": "^1.6.0",
"react-native-swiper-flatlist": "^3.2.4",
"react-native-vector-icons": "^10.1.0",
"react-native-web": "~0.19.10",
"tailwindcss": "^3.3.2",
"expo-asset": "~10.0.8"

},

//app.js

useEffect(() => {
loadResources();
}, []);

const loadResources = async () => {
try {
await Asset.loadAsync([
require("./assets/allcoin.png"),
require("./assets/google.png"),
require("./assets/apple-logo.png"),
require("./assets/splash.png"),
require("./assets/onboard1.webp"),
require("./assets/fastpay.png"),
require("./assets/splash.png"),
require("./assets/background.png"),
]);
setImagesLoaded(true);
checkUserToken();
} catch (error) {
console.error("Error loading resources:", error);
}
};

@chriscoomber
Copy link

chriscoomber commented Jun 12, 2024

Regarding the issue with IS_ENV_WITH_LOCAL_ASSETS, I would recommend using the following diff with patch-package:

--- a/node_modules/expo-asset/build/PlatformUtils.web.js
+++ b/node_modules/expo-asset/build/PlatformUtils.web.js
 export const IS_ENV_WITH_UPDATES_ENABLED = false;
+export const IS_ENV_WITH_LOCAL_ASSETS = false;
 // Compute manifest base URL if available
 export const manifestBaseUrl = null;
 export function getManifest() {

basically just add the missing const export - which is always going to be false because local assets are meaningless on web

@dylansproule
Copy link

Has a PR been put up for this change mentioned @chriscoomber ?

@chriscoomber
Copy link

@dylansproule I've not made one - I don't really know for sure what this code is doing, I was just suggesting what fixed it for me.

@d4rky-pl
Copy link
Contributor

@dylansproule @chriscoomber ran into the same issue so I sent a PR: #29839

@KrisLau
Copy link

KrisLau commented Jun 20, 2024

This has been fixed in the latest expo version from what i can tell! expo v51.0.14

@Arnavpmr
Copy link

@KrisLau It has not been fixed for me. I also get the issue with the missing crypto package so I don't know if the patch addresses that issue as well.

@KrisLau
Copy link

KrisLau commented Jun 24, 2024

@Arnavpmr you might wanna try running react-native clean-project-auto and if that fails, delete your package-lock.json (might want to git commit or save a copy if the package-lock before doing this so you can rollback if need be) and try installing the packages again, run the clean auto command, install again, then run again.

If that doesn't work, then your issue might be related to a different thing from the patch.

@Arnavpmr
Copy link

@KrisLau I appreciate your suggestion but it didn't work unfortunately. I digged through the code for expo-asset in the npm repository and it wasn't updated with the latest patch. I believe that's probably why I'm not getting that patch so I can just wait for it to be rolled out to that package.

@deemyboy
Copy link

deemyboy commented Aug 16, 2024

I upgraded Expo SDK from 50 to 51 which broke assets loading

The actual error was "ERROR TypeError: Cannot read property 'uri' of null...
...info Opening /Users/abdullah/development/projects-ab/calc/node_modules/expo-asset/build/Asset.js"
with code

this pointed to a file in node_modules --> node_modules/expo-asset/build/Asset.js

the null property was "virtualAssetModule"

so, after googling "virtualAssetModule expo 51"

I found this post on Reddit

https://x.com/hirbod_dev/status/1798178985463181598?s=46&t=BJ6679qzsf66cZNyHJdrlA

it mentioned

"Upgraded from Expo 49 to 51 and local assets not loaded
I recently upgraded to Expo 51 coming from 49 and on that version I loaded some images from the /assets/images folder."

It also provided a solution from X (Twitter in the good ole days)

https://x.com/hirbod_dev/status/1798178985463181598?s=46&t=BJ6679qzsf66cZNyHJdrlA

add a resolution for "react-native/assets-registry": "0.74.83" because because "0.74.84" breaks assets loading!

so now part of my package.json looks like this

"resolutions": {
    "@react-native/assets-registry": "0.74.83" 
  }

after running "yarn"

then stopping the server (ctrl-c on mac terminal) then running "yarn start" which in my case runs this script in package.json

"start": "npx expo start -c",

the problem was fixed STRAIGHT AWAY!

hope this helps someone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.