Image assets fail to render in Yarn workspace monorepo with React Native 0.81.* and NX
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, react-native
- Domain
- build-system
Research direction
Start by reproducing the issue with the provided Yarn workspace layout, React Native 0.81.5, NX, and the shown Metro configuration, using nx start <project>. Compare asset imports from the application directory with imports from @someWorkspace/assets, and review related issues 1599 and 1614. Done means shared-package image assets resolve and render without requiring them to be moved into the app.
Written by the indexing model from the issue text.
Description
Description
Image assets fail to render in Yarn workspace monorepo with React Native 0.81.* and NX.
If move assets into application's directory then metro resolves them correctly. But if assets are located in outside application's directory in the monorepo then bundler can not resolve them.
FAILS TO RESOLVE:
repo-root/
├─ apps/
│ └─ someApp/
│ ├─ src/
│ │ └─ App.tsx
│
└─ packages/
└─ assets/ ← asset lives OUTSIDE the app
├─ images/
│ └─ logo.svg
SUCCESSFULLY RESOLVES:
repo-root/
│
├─ apps/
│ └─ someApp/
│ ├─ src/
│ ├─ assets/
│ │ └─ logo.svg ← asset lives INSIDE the app
│ │ └─ App.tsx
│
└─ packages/
Environment
- React Native: 0.81.5
- React: 19.1.0
- Yarn: 4.x (workspaces) and 1.22.22
- Node: 22.x
- OS: macOS 15 (M1 Pro)
- Bundler: Metro (default)
Relevant dependencies
{
"@react-native/metro-config": "0.81.5",
"@react-native/babel-preset": "0.81.5",
"@react-native/typescript-config": "0.81.5",
"react-native-svg-transformer": "1.5.1",
"react-native": "0.81.5",
"react": "19.1.0",
"nx": "21.6.3",
"@nx/react-native": "21.6.3"
}
App usage
// packages/mobile/App.tsx
import React from 'react'
import { Image } from 'react-native'
export const App = () => (
<Image source={require('@someWorkspace/assets/logo.png')} style={{ width: 64, height: 64 }} />
)
When run
nx start <project>
Metro config:
const {withNxMetro} = require('@nx/react-native');
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const {
getMetroAndroidAssetsResolutionFix,
} = require('react-native-monorepo-tools');
const {withDatadogMetroConfig} = require('@datadog/mobile-react-native/metro');
const assetsFix = getMetroAndroidAssetsResolutionFix();
const defaultConfig = getDefaultConfig(__dirname);
const {assetExts, sourceExts} = defaultConfig.resolver;
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const customConfig = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
publicPath: assetsFix.publicPath,
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'cjs', 'mjs', 'svg'],
},
server: {
enhanceMiddleware: assetsFix.applyMiddleware,
},
};
module.exports = withNxMetro(
withDatadogMetroConfig(mergeConfig(defaultConfig, customConfig)),
);
NX project config:
{
"name": "projectName",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/someApp/src",
"projectType": "application",
"tags": ["app"],
"targets": {
"start": {
"executor": "@nx/react-native:start",
"dependsOn": ["sync-deps"],
"options": {
"port": 8081,
"resetCache": true
}
}
}
...Other config
}
The app builds and runs, but the image renders as an empty space.
Expected behavior
Metro/React Native should correctly resolve and bundle static image assets exported from shared workspace packages — the same way it handles JS modules.
Actual behavior
When importing images from another workspace (e.g., @someWorkspace/assets), the app runs without any build or runtime error, but the image simply does not appear.
Screenshots / recordings
Related issues:
Additional info:
Possible fixes from above issues didn't work out.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 702
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 50
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from react/metro
-
constant-folding-plugin emits 0/0 (NaN) for arithmetic on destructured bindingsPossibly taken @cpruijsen claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/metro#1927 · 1 comment ·
Maintainers usually reply within 2 days
-
[0.83.x] Backport micromatch removal and dotfile/multipart watcher fix togetherPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 2 days
-
`dependencies is not iterable` / `Cannot read property 'reduce' of undefined`: `FileStore` serves zero-prefixed cache files as hitsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
react/metro#1961 · 1 comment ·
Maintainers usually reply within 2 days
-
Async chunk URLs drop the file extension, so .cjs async imports fail with "Requiring unknown module"Possibly taken @dasjideepak claimed this 14 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 74/100
react/metro#1959 · 2 comments · 2 reactions ·
Maintainers usually reply within 2 days
-
Files changed during startup can be missed until restartPossibly taken @cpruijsen claimed this 2 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/playwright#43327 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/TypeScript#64758 ·
Maintainers usually reply within 1 day
-
needs-area-label
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
bug good first issue help wanted status: planned
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
andersthemagi/reliquary#310 ·
Maintainers usually reply within 1 day