几天前我在 Facebook/react-native 上创建了一个问题,但尚未收到回复。 为了尝试让我启动并运行,我也会在这里询问。 问题链接
我检查了有关此事的其他 SO 帖子,但没有任何建议有帮助。
我正在按照 Mac/iOS 的入门文档创建 AwesomeProject 示例应用程序。当我开始项目时使用
npx react-native start
并在 Xcode 中构建 iOS 应用程序,应用程序启动(在模拟器中)以显示白色启动画面,顶部显示“正在从 Metro 加载...”。 大约一分钟后,我收到以下错误:
Could not connect to development server.
Ensure the following:
- Node server is running and available on the same network - run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate
- WiFi is enabled and connected to the same network as the Node Server
URL: http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.AwesomeProject
在我启动服务器的终端中,我看到:
2021-11-13T16:46:53,199: [cli] unable to talk to your watchman on /usr/local/var/run/watchman/chrisluxoft-state/sock! (No such file or directory)
Watchman: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2021-11-13T16:46:53,199: [cli] unable to talk to your watchman on /usr/local/var/run/watchman/chrisluxoft-state/sock! (No such file or directory)
我导航至
/usr/local/var/run/watchman/chrisluxoft-state/
并且目录中没有文件。
我跑了
watchman --foreground --logfile=[pathtodesktop]/log.txt
按照建议here,生成以下日志:
2021-11-13T16:49:35,574: [listener] Watchman 2021.11.08.00 <no build info set> starting up on Grey-Mac.local
2021-11-13T16:49:35,581: [listener] file limit is 2560 kern.maxfilesperproc=49152
2021-11-13T16:49:35,581: [listener] raised file limit to 49152
2021-11-13T16:49:35,581: [listener] launchd checkin failed: No such process
2021-11-13T16:49:35,582: [sanitychecks] starting sanityCheckThread
当我回到
/usr/local/var/run/watchman/chrisluxoft-state/
我看到现在有两个文件:pid & sock=
受此鼓舞,我重新启动进程并在 Xcode 中重建应用程序。 结果相同,只是这次终端的错误是:
2021-11-13T16:56:49,310: [cli] unable to talk to your watchman on /usr/local/var/run/watchman/chrisluxoft-state/sock! (Connection refused)
Watchman: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2021-11-13T16:56:49,310: [cli] unable to talk to your watchman on /usr/local/var/run/watchman/chrisluxoft-state/sock! (Connection refused)
再看一遍
/usr/local/var/run/watchman/chrisluxoft-state/
我看到相同的两个文件。 我期望有一个日志文件,但它不存在。
这是在具有多个用户帐户的 Mac 上,如果这有影响(即权限)。
node、react-native、watchman 是由 Homebrew 安装的。我使用相同的用户帐户进行安装和执行。
反应原生信息
System:
OS: macOS 11.6.1
CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
Memory: 1.65 GB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 17.0.1 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.1.0 - /usr/local/bin/npm
Watchman: 2021.11.08.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /Volumes/WD_Internal/chrisluxoft/.rvm/gems/ruby-2.7.4/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7784292
Xcode: 13.0/13A233 - /usr/bin/xcodebuild
Languages:
Java: 11.0.12 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.3 => 0.66.3
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Mackbook 总是请求访问我们的文档文件夹的权限,如果您想提供它,那么您将收到上述错误。 索尔...只需关闭所有选项卡并重新启动您的电脑即可。然后系统会自动询问访问内部文件的权限。