Skip to content

Cannot run fresh created example app #842

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

Closed
1 of 2 tasks
slavkolukic opened this issue May 14, 2025 · 4 comments
Closed
1 of 2 tasks

Cannot run fresh created example app #842

slavkolukic opened this issue May 14, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@slavkolukic
Copy link

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

@slavkolukic slavkolukic added the bug Something isn't working label May 14, 2025
@satya164
Copy link
Member

@samcarton
Copy link

samcarton commented May 26, 2025

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
Copy link
Member

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

@samcarton
Copy link

samcarton commented May 26, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants