Application XXX has not been registered.【RN0.60】

742 阅读1分钟

错误描述

Application MyTest has not been registered. This is either due to a require() error during initialization or failure to call AppRegistry.registerComponent.

初始化RN项目时,有时候会报这个错误。通常有两种情况引发

  • 1.AppRegistry.registerComponent(appName, () => XXX);检查一下XXX是否是你要显示的初始化组件。
  • 2.端口被占用。一般默认端口为8081.检查方式。切换到项目所在目录,输入react-native start 如果出现Packager can‘t listen on port 8081那说明端口被占用了。

解决方式:

  • 1.打开终端lsof -n -i4TCP:8081 列出被占用的端口列表
  • 2.kill -9 xxx 找到与之对应的PID然后删除即可
  • 3.react-native run-ios/android 重新运行项目