react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.41k stars 905 forks source link

Metro server no longer runs automatically on certain startup commands #2530

Open coolsoftwaretyler opened 1 month ago

coolsoftwaretyler commented 1 month ago

Environment

System:
  OS: macOS 14.6
  CPU: (16) arm64 Apple M3 Max
  Memory: 18.09 GB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.8.0
    path: ~/.asdf/installs/nodejs/22.8.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.asdf/shims/yarn
  npm:
    version: 10.8.2
    path: ~/.asdf/plugins/nodejs/shims/npm
  Watchman:
    version: 2024.09.30.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/tylerwilliams/.asdf/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.21829.142.2421.12409432
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 3.3.4
    path: /Users/tylerwilliams/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.3
    wanted: 0.75.3
  react-native-macos:
    installed: 0.75.6
    wanted: ^0.75.0-0
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Description

I first noticed this while working in an out-of-tree platform, React Native MacOS. Running npx react-native run-macos did not start Metro automatically. Filed the full set of details originally in their project at https://github.com/microsoft/react-native-macos/issues/2208

But I got a notificaiton about the "removing run on iOS/Android key handlers" discussion about this comment: https://github.com/react-native-community/discussions-and-proposals/discussions/821#discussioncomment-10852786

not opposed to this change (alongside the above, it also seems less confusing to only have one entry point), but I do want to note that, at least for me, yarn android doesn't seem to start Metro? I'm using Ubuntu 24.04/GNOME Terminal if it matters - I swear it did work (at least occasionally) on Windows but I'm not certain about that

And I thought it might be related to what I had seen on React Native MacOS.

Reproducible Demo

Follow the React Native macOS setupd (for the most part, the current docs are actually a little out of date, but this will be the steps for an up-to-date RN project)

  1. npx @react-native-community/cli init macapp
  2. cd macapp
  3. npx react-native-macos-init
  4. npx react-native run-macos

The app will build, but not start Metro:

image

Not a big deal, I can just run yarn start, then tap "reload"

Everything works great from there. I also did not have this issue when following the instructions for RN 0.71:

npx react-native@latest init <projectName> --version 0.71.0

Reproducer repo: https://github.com/coolsoftwaretyler/rnms-issue-repro

It sounds like this is happening on in-tree platforms as well based on @Rexogamer's comment in that discussion post, but I don't have a reproduction for that at the moment.

Thanks for your work and consideration!

alainib commented 3 weeks ago

no matter what i do i cannot run on ios now. bundle is not found

Make sure you're running a packager server or have included a .jsbundle file in your application bundle. npx react-native bundle

how to solve this please ? maybe i was on a previous version of react-native-cli before, i tryed to update to RN 76 but failed , so i cleaned temp files, now it stuck i use react-native 0.74.5 which version of react-native-cli i shoud use please ? 2.0.1 ? thanks