Skip to content
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

npx react-native run-macos in a new project is launching code in an unrelated project #2119

Closed
michelcrypt4d4mus opened this issue May 13, 2024 · 2 comments
Labels
bug Something isn't working Needs: Triage 🔍

Comments

@michelcrypt4d4mus
Copy link

michelcrypt4d4mus commented May 13, 2024

Environment

react-native -v: 10.0
npm ls react-native-macos: react-native-macos@0.71.36
node -v: v21.7.2
npm -v: 10.5.0
yarn --version: n/a
xcodebuild -version: xcodebuild -version
macOS: 13.6.4

Steps to reproduce the bug

I created a new project:

npx react-native@latest init project1 --version 0.71.0
cd project1
npx react-native-macos-init

Launched it with npx react-native run-macos - so far so good. Did a bit of work on it trying to get some old react components to work, ran into an issue, decided to start over. To be specific I had tried to import @reduxjs/toolkit which was somehow not being found and so the app barfed before it even instantiated <App>. So i backed up and made a totally unrelated project:

npx react-native@latest init project2--version 0.71.0
cd project2
npx react-native-macos-init

However now when I try to launch project2 with npx react-native run-macos the app window comes up and i get an error about how it cannot find @reduxjs/toolkit when it tries to compile source code that lives in the project1 directory tree???

Expected Behavior

I expect a new project to have absolutely no dependency or relationship of any kind to the old project.

Actual Behavior

I have repeated this now with several new projects and the result is always the same - no matter what project i create or where i create it the react-native app that comes up when i run npx react-native run-macos is always trying to run code in project1 (and failing because of a reference to @reduxjs/toolkit)

i scanned my environment for any weird env vars, found nothing. at a loss as to how to proceed here.

Reproducible Demo

The default project that gets built by npx react-native@latest init project2 --version 0.71.0 reproduces this just fine.

Additional context

No response

@michelcrypt4d4mus
Copy link
Author

I just tried to make yet another new project after moving project1 out of the way and now I at least get a more descriptive error even though it's still trying to run code from project:

Metro has encountered an error: ENOENT no such file or directory, lstat '/Users/uzor/work/project1': node:fs (2702:29)

@michelcrypt4d4mus
Copy link
Author

this was caused by (at a minimum) metro bundler failing to exit after being launched the first time which is unexpected. unclear if that's really the fault of react-native-macos but it was definitely unexpected behavior for a newcomer.

if anyone else runs into this issue you can (usually) find the process ID of metro bundler by looking to see if any processes are holding port 8081 (metro bundler's default port) with lsof -t -i :8081

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

No branches or pull requests

1 participant