RN 0.87 compatibility - Metro fails to resolve `@react-native/assets-registry/registry` when importing from `react-native-svg/css`
Description
After upgrading to React Native 0.87, Metro fails when bundling code that imports from react-native-svg/css (e.g. SvgCssUri).
ERROR Error: Unable to resolve module @react-native/assets-registry/registry from .../react-native-svg/src/lib/resolveAssetUri.ts: @react-native/assets-registry/registry could not be found within the project or in these directories:
node_modules
> 7 | import { getAssetByID } from '@react-native/assets-registry/registry';Expected: Imports from react-native-svg/css bundle successfully on RN 0.87.
Actual: Metro cannot resolve @react-native/assets-registry/registry.
Root cause: [email protected] imports @react-native/assets-registry/registry in src/lib/resolveAssetUri.ts, which is used by the /css subpath (LocalSvg.tsx → resolveAssetUri.ts). React Native 0.87 no longer lists @react-native/assets-registry as a dependency of react-native (it was present in 0.86). The package is therefore not installed transitively.
Workarounds:
- Add
@react-native/[email protected]as a direct dependency. - Metro alias:
'@react-native/assets-registry/registry'→react-native/asset-registry.
Steps to reproduce
Create a fresh RN 0.87 app (
npx @react-native-community/cli init).Install
[email protected].Import from the
/csssubpath:import { SvgCssUri } from 'react-native-svg/css'; export function App() { return <SvgCssUri uri="https://example.com/icon.svg" width={100} height={100} />; }Run Metro (
npx react-native start) or bundle (npx react-native bundle --platform ios --dev true --entry-file index.js --bundle-output /tmp/test.bundle).Observe the
@react-native/assets-registry/registryresolution error.
Snack or a link to a repository
https://github.com/SimpleCreations/SEE_STEPS_TO_REPRODUCE
SVG version
15.15.5
React Native version
0.87.0
Platforms
Android, iOS
JavaScript runtime
Hermes
Workflow
React Native
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
iOS simulator
Device model
No response
Acknowledgements
Yes
Source: software-mansion/react-native-svg