-
Notifications
You must be signed in to change notification settings - Fork 221
Description
Description
After creating a new project using create-react-native-library
, I followed the standard steps to set up and run the example project. However, running npm start
results in a error:
BUNDLE ./index.js
ERROR Error: Unable to resolve module react-native from /Users/foo/code/create-react-native-library-example/example/index.js: react-native could not be found within the project or in these directories:
node_modules
../node_modules
/Users/foo/code/create-react-native-library-example/node_modules/react-native
> 1 | import { AppRegistry } from 'react-native';
| ^
2 | import App from './src/App';
3 | import { name as appName } from './app.json';
4 |
at ModuleResolver.resolveDependency (/Users/foo/code/create-react-native-library-example/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:150:15)
at DependencyGraph.resolveDependency (/Users/foo/code/create-react-native-library-example/node_modules/metro/src/node-haste/DependencyGraph.js:239:43)
at /Users/foo/code/create-react-native-library-example/node_modules/metro/src/lib/transformHelpers.js:161:21
at resolveDependencies (/Users/foo/code/create-react-native-library-example/node_modules/metro/src/DeltaBundler/buildSubgraph.js:43:25)
at visit (/Users/foo/code/create-react-native-library-example/node_modules/metro/src/DeltaBundler/buildSubgraph.js:81:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 0)
at async buildSubgraph (/Users/foo/code/create-react-native-library-example/node_modules/metro/src/DeltaBundler/buildSubgraph.js:105:3)
at async Graph._buildDelta (/Users/foo/code/create-react-native-library-example/node_modules/metro/src/DeltaBundler/Graph.js:158:22)
at async Graph.initialTraverseDependencies (/Users/foo/code/create-react-native-library-example/node_modules/metro/src/DeltaBundler/Graph.js:141:19)
I’m pretty sure I have run npm install
successfully, and I can see that react-native
is present in the node_modules
folder. Please let me know if there are additional setup steps required or if this is a bug in the generated project structure.
Steps to reproduce
- npx create-react-native-library my-lib`
- cd my-lib
- npm install
- cd example
- npm install
- npm start
- run ios/android app or simply hit http://localhost:8081/index.bundle
Packages
- create-react-native-library
- react-native-builder-bob
Selected options
Turbo Modules
Link to repro
https://github.com/kukat/create-react-native-library-example
Environment
System:
OS: macOS 15.6.1
CPU: (10) arm64 Apple M1 Pro
Memory: 194.22 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.19.4
path: ~/.local/share/mise/installs/node/20.19.4/bin/node
Yarn: Not Found
npm:
version: 10.8.2
path: ~/.local/share/mise/installs/node/20.19.4/bin/npm
Watchman:
version: 2025.09.08.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /Users/foo/.local/share/mise/installs/ruby/3.4.5/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.5
- iOS 18.5
- macOS 15.5
- tvOS 18.5
- visionOS 2.5
- watchOS 11.5
Android SDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.26094.121.2513.14007798
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 21.0.8
path: /Users/foo/.local/share/mise/installs/java/temurin-21.0.8+9.0.LTS/bin/javac
Ruby:
version: 3.4.5
path: /Users/foo/.local/share/mise/installs/ruby/3.4.5/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: false