This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
“你需要登录 Expo Go 和 Expo CLI”的错误
了解为什么在实体 iOS 设备上使用 Expo Go 需要 Expo CLI 和 Expo Go 登录同一个 Expo 账号。
当 Expo CLI 和 Expo Go 都没有登录时,Expo Go 在真实 iOS 设备上会显示以下错误:
🌐 Expo Go displays the following error on a physical iOS device when neither Expo CLI nor Expo Go is signed in:
You need to be signed in to Expo Go and Expo CLI to open your project. Run "npx expo login" on your computer to sign in with Expo CLI.
当一方已登录而另一方未登录,或者两个账户不同,你会看到下面的其中一种情况:
🌐 When one side is signed in and the other is not, or the two accounts differ, you see one of these instead:
You're signed in to Expo Go as "your-account", but not signed in to Expo CLI. Run "npx expo login" on your computer to sign in to Expo CLI as "your-account" so you can open this project. You're signed in to Expo CLI as "your-account", but not signed in to Expo Go. Sign in to Expo Go as "your-account" to open this project. You're signed in to Expo CLI as "your-account" and to Expo Go as "another-account" — these accounts need to match to open this project.
Expo CLI 不会报告这些。开发服务器继续运行,终端没有任何警告,所以错误只会在你的设备上出现。
🌐 Expo CLI does not report any of this. The development server keeps running with no warning in the terminal, so the error appears only on your device.
为什么会这样
🌐 Why this happens
在真实的 iOS 设备上,Expo Go 会在打开项目之前检查 Expo 账户。Expo CLI 和 Expo Go 必须登录同一个 Expo 账户。
🌐 On a physical iOS device, Expo Go checks for the Expo account before it opens a project. Expo CLI and Expo Go must be signed in to the same Expo account.
这个检查只适用于实际的 iOS 设备,并且只针对从开发服务器提供的项目。Android 设备、Android 模拟器、iOS 模拟器以及已发布的更新不受影响。
🌐 The check applies to physical iOS devices only and only to a project served from a development server. Android devices, the Android Emulator, the iOS Simulator, and published updates are unaffected.
登录同一个账户
🌐 Sign in to the same account
如果你没有 Expo 账户,可以在 expo.dev/signup 免费创建一个。
🌐 If you do not have an Expo account, create a free one at expo.dev/signup.
在你的电脑上登录 Expo CLI:
🌐 Sign in to Expo CLI on your computer:
然后,在你的设备上打开 Expo Go,点击右上角的账户图标,并用同一个账号登录。
🌐 Then, open Expo Go on your device, tap the account icon in the top-right corner, and sign in with the same account.
要查看 Expo CLI 使用的是哪个账户,运行:
🌐 To check which account Expo CLI is using, run:
重新加载项目
🌐 Reload the project
在 Expo Go 错误屏幕上按 重试。每次 Expo Go 请求项目时,Expo CLI 都会读取你的凭证,所以只要在开发服务器运行时登录就够了。
🌐 Press Try Again on the Expo Go error screen. Expo CLI reads your credentials each time Expo Go requests the project, so signing in while the development server runs is enough.
如果你登录了不同的账号,请重启开发服务器。Expo CLI 会在进程的整个生命周期中缓存已解析的账号。
🌐 Restart the development server if you sign in to a different account. Expo CLI caches the resolved account for the lifetime of the process.