Skip to content

Cannot run fresh created example app #842

Closed
@slavkolukic

Description

@slavkolukic

Description

  1. I used npx create-react-native-library@latest issue-min-repro command and selected JavaScript Library.
  2. Navigated to issue-min-repro and ran yarn to install deps.
  3. Ran yarn example ios
  4. Got the following error:
The package `/Users/slavkolukic/Desktop/issue-min-repro/package.json` is invalid because it specifies a `main` module field that could not be resolved (`/Users/slavkolukic/Desktop/issue-min-repro/lib/module/index.js`. None of these files exist:

  * /Users/slavkolukic/Desktop/issue-min-repro/lib/module/index.js(.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.mjs|.native.mjs|.mjs|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.cjs|.native.cjs|.cjs|.ios.scss|.native.scss|.scss|.ios.sass|.native.sass|.sass|.ios.css|.native.css|.css)
  * /Users/slavkolukic/Desktop/issue-min-repro/lib/module/index.js/index(.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.mjs|.native.mjs|.mjs|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.cjs|.native.cjs|.cjs|.ios.scss|.native.scss|.scss|.ios.sass|.native.sass|.sass|.ios.css|.native.css|.css)
    at resolvePackageEntryPoint (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/metro-resolver/src/resolve.js:330:11)
    at resolveModulePath (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/metro-resolver/src/resolve.js:189:21)
    at resolvePackage (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/metro-resolver/src/resolve.js:293:10)
    at resolver (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/metro-resolver/src/resolve.js:128:20)
    at doResolve (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/@expo/cli/src/start/server/metro/withMetroMultiPlatform.ts:277:14)
    at resolver (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/@expo/cli/src/start/server/metro/withMetroMultiPlatform.ts:615:22)
    at Object.resolveRequest (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/@expo/cli/src/start/server/metro/withMetroResolvers.ts:76:29)
    at firstResolver (file:///Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/react-native-monorepo-config/index.js:171:26)
    at firstResolver (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/@expo/cli/src/start/server/metro/withMetroResolvers.ts:108:16)
    at resolveRequest (/Users/slavkolukic/Desktop/issue-min-repro/example/node_modules/@expo/cli/src/start/server/metro/withMetroResolvers.ts:137:16)

Screenshot of the error:

Image

Packages

  • create-react-native-library
    react-native-builder-bob

Selected options

JavaScript Library

Link to repro

https://github.com/slavkolukic/react-native-issue-min-repro

Environment

info Fetching system and libraries information...
System:
OS: macOS 15.1
CPU: (8) arm64 Apple M1 Pro
Memory: 201.95 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.15.0
path: ~/.nvm/versions/node/v22.15.0/bin/node
Yarn:
version: 3.6.1
path: ~/.nvm/versions/node/v22.15.0/bin/yarn
npm:
version: 10.9.2
path: ~/.nvm/versions/node/v22.15.0/bin/npm
Watchman:
version: 2023.06.08.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.12.1
path: /Users/slavkolukic/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.1
- iOS 18.1
- macOS 15.1
- tvOS 18.1
- visionOS 2.1
- watchOS 11.1
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 16.1/16B40
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.24
path: /usr/bin/javac
Ruby:
version: 2.7.6
path: /Users/slavkolukic/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: ^18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.2
wanted: 0.79.2
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

Activity

added a commit that references this issue on May 15, 2025
3001529
satya164

satya164 commented on May 15, 2025

@satya164
Member
samcarton

samcarton commented on May 26, 2025

@samcarton

hi @satya164 I am having the same issue but my metro.config.js already looks like the linked version.
when you say

Or add "source": "./index.tsx" in package.json.

what exactly do you mean? I've tried adding it to the example/package.json but doesn't seem to have helped

satya164

satya164 commented on May 26, 2025

@satya164
Member

@samcarton add it to the root package.json, not in the example.

samcarton

samcarton commented on May 26, 2025

@samcarton

@satya164 thanks for the quick reply. I found that it was actually because my TSconfig was based on another TSconfig in our monorepo that was somehow causing the error - I updated it to be the exact same as the generated TSconfig and it worked without adding "source": "./index.tsx" in package.json.

added a commit that references this issue on May 26, 2025
72d95df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @satya164@samcarton@slavkolukic

        Issue actions

          Cannot run fresh created example app · Issue #842 · callstack/react-native-builder-bob