Metro unable to resolve nx libraries after upgrade from RN 0.72.8

When trying to start the application, Metro doesn’t compile the React Native app because:
Metro has encountered an error:

Error: Cannot resolve package.json
    at /Users/michaelwijnands/Projects/myapp-frontend-3/node_modules/@nx/react-native/plugins/metro-resolver.js:31:15
    at Object.resolve (/Users/michaelwijnands/Projects/myapp-frontend-3/apps/mobile/node_modules/metro-resolver/src/resolve.js:32:12)
    at ModuleResolver.resolveDependency (/Users/michaelwijnands/Projects/myapp-frontend-3/apps/mobile/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:73:31)
    at DependencyGraph.resolveDependency (/Users/michaelwijnands/Projects/myapp-frontend-3/apps/mobile/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
    at /Users/michaelwijnands/Projects/myapp-frontend-3/apps/mobile/node_modules/metro/src/lib/transformHelpers.js:156:21
    at resolveDependencies (/Users/michaelwijnands/Projects/myapp-frontend-3/apps/mobile/node_modules/metro/src/DeltaBundler/buildSubgraph.js:42:25)
    at visit (/Users/michaelwijnands/Projects/myapp-frontend-3/apps/mobile/node_modules/metro/src/DeltaBundler/buildSubgraph.js:83:30)
    at async Promise.all (index 0)
    at async visit (/Users/michaelwijnands/Projects/myapp-frontend-3/apps/mobile/node_modules/metro/src/DeltaBundler/buildSubgraph.js:92:5)
    at async Promise.all (index 4)

When setting debug to true in metro.config.js, I notice a lot of errors saying:

[Nx] Unable to resolve with default Metro resolver: @myappname/my-hn/icons
[Nx] Unable to resolve with default resolveRequest: @myappname/my-hn/theme
[Nx] Unable to resolve with default Metro resolver: @myappname/my-hn/theme
[Nx] Unable to resolve with default resolveRequest: @myappname/my-hn/theme
[Nx] Unable to resolve with default Metro resolver: @myappname/my-hn/theme
[Nx] Unable to resolve with default resolveRequest: @myappname/my-hn/icons
[Nx] Unable to resolve with default Metro resolver: @myappname/my-hn/icons
[Nx] Unable to resolve with default resolveRequest: @myappname/my-hn/config
[Nx] Unable to resolve with default Metro resolver: @myappname/my-hn/config

My metro.config.js:

const { withNxMetro } = require('@nx/react-native');
const { workspaceRoot } = require('@nx/devkit');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const path = require('path');

const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;

/**
 * Metro configuration
 * https://facebook.github.io/metro/docs/configuration
 *
 * @type {import('metro-config').MetroConfig}
 */
const customConfig = {
  transformer: {
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
  },
  resolver: {
    assetExts: assetExts.filter((ext) => ext !== 'svg'),
    sourceExts: [...sourceExts, 'cjs', 'mjs', 'svg', 'json'],
  },
};

module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
  // Change this to true to see debugging info.
  // Useful if you have issues resolving modules
  debug: true,
  // all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
  extensions: [],
  // Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
  watchFolders: [path.resolve(__dirname, '../../node_modules'), path.resolve(__dirname, '../../libs/my-hn')],
});

One of the libs, @myappname/my-hn/config, only has 3 small TypeScript files. These files export some string etc, no rocket science or any heavy code at all. All other libs also are TS files.

Steps to Reproduce

  1. Create a NX library that works on both React and React Native
  2. Upgrade from RN 0.72.8 to 0.73.2 (we also tried 0.74.1 as NX migrate latest does)
  3. Start the run-ios or run-android command

Nx Report

Node   : 18.20.2
OS     : darwin-arm64
npm    : 10.5.0

nx                 : 19.5.2
@nx/js             : 19.5.2
@nx/jest           : 19.5.2
@nx/linter         : 19.5.2
@nx/eslint         : 19.5.2
@nx/workspace      : 19.5.2
@nx/angular        : 19.5.2
@nx/detox          : 19.5.2
@nx/devkit         : 19.5.2
@nx/eslint-plugin  : 19.5.2
@nx/express        : 19.5.2
@nx/node           : 19.5.2
@nx/react          : 19.5.2
@nx/react-native   : 19.5.2
@nrwl/tao          : 19.5.2
@nx/web            : 19.5.2
@nx/webpack        : 19.5.2
typescript         : 5.0.4
---------------------------------------
Community plugins:
@ionic/angular              : 6.7.5
@maskito/angular            : 1.9.0
@nguniversal/builders       : 16.2.0
@nguniversal/express-engine : 16.2.0
@nxext/capacitor            : 18.0.4
apollo-angular              : 5.0.2
ngx-bootstrap               : 11.0.2

Additional Information

Yes, we also have an Angular app in our repo as we are currently migrating from Angular (web-app) with an Ionic app (mobile) to React and React Native.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật