react / react/react-native

Invariant Violation: "main" has not been registered. This can happen if:

Đang mở
#53,685 13 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Needs: Attention Needs: Repro Stale
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

Description

I have run the react native project for android and got the error on the emulator screen just after opening it.

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
Steps to reproduce

Install application and yarn android.

React Native Version

0.79.5

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: Windows 11 10.0.26100
  CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13650HX
  Memory: 18.30 GB / 39.69 GB
Binaries:
  Node:
    version: 22.14.0
    path: C:\nvm4w\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: C:\nvm4w\nodejs\yarn.CMD
  npm:
    version: 10.9.2
    path: C:\nvm4w\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "34"
      - "35"
    Build Tools:
      - 34.0.0
      - 34.0.0
      - 34.0.0
      - 34.0.0
      - 35.0.0
      - 35.0.0
      - 35.0.0
      - 35.0.0
      - 35.0.0
      - 35.0.1
      - 36.0.0
    System Images:
      - android-34 | Google APIs Intel x86_64 Atom
      - android-34 | Google Play Intel x86_64 Atom
      - android-35 | Google Play Intel x86_64 Atom
      - android-35 | Pre-Release 16 KB Page Size Google Play Intel x86_64 Atom
      - android-36 | Google APIs Intel x86_64 Atom
      - android-36 | Google Play Intel x86_64 Atom
      - android-36 | Pre-Release 16 KB Page Size Google APIs Intel x86_64 Atom
    Android NDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-243.24978.46.2431.13363775
  Visual Studio: Not Found
Languages:
  Java:
    version: 17.0.10
    path: /c/Program Files/Java/jdk-17/bin/javac
  Ruby: Not Found
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.5
    wanted: 0.79.5
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.81.1 is now available (your project is running on v0.79.5).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.81.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.5&to=0.81.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows".
Stacktrace or Logs
09-09 19:19:29.561  4602  4779 E ReactNativeJS: ReferenceError: Property 'document' doesn't exist, js engine: hermes
09-09 19:19:29.580  4602  4779 I ReactNativeJS: Running "main" with {"rootTag":11}
09-09 19:19:29.582  4602  4779 E ReactNativeJS: Invariant Violation: "main" has not been registered. This can happen if:
09-09 19:19:29.582  4602  4779 E ReactNativeJS: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
09-09 19:19:29.582  4602  4779 E ReactNativeJS: * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
MANDATORY Reproducer

...

Screenshots and Videos
Image

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện với yarn android và kiểm tra lỗi Hermes xảy ra trước đó, đặc biệt là ReferenceError: Property 'document' doesn't exist; xác minh Metro được khởi chạy từ thư mục dự án và lần theo module bị lỗi trước AppRegistry.registerComponent. Công việc được xem là hoàn tất khi nguyên nhân của lỗi đã được xác nhận và có bản sửa lỗi có thể tái hiện, hoặc đã ghi lại rằng lỗi bắt nguồn từ ứng dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, react-native
Lĩnh vực
mobile-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
28/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.