This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

"You need to be signed in to Expo Go and Expo CLI" 错误

编辑页面

了解为什么在实体 iOS 设备上使用 Expo Go 时,Expo CLI 和 Expo Go 需要登录同一个 Expo 账号。


当 Expo CLI 和 Expo Go 均未登录时,Expo Go 会在实体 iOS 设备上显示以下错误:

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.

如果一方已登录而另一方未登录,或者双方登录的账号不同,则会看到以下错误之一:

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 不会报告这些情况。开发服务器会继续运行,终端中不会显示任何警告,因此只有设备会显示错误。

为什么会出现这种情况

在实体 iOS 设备上,Expo Go 会在打开项目之前检查 Expo 账号。Expo CLI 和 Expo Go 必须登录同一个 Expo 账号。

此检查仅适用于实体 iOS 设备,且仅适用于由开发服务器提供服务的项目。Android 设备、Android Emulator、iOS Simulator 和已发布的更新不受影响。

登录同一个账号

如果你没有 Expo 账号,可以在 expo.dev/signup 免费创建一个。

在电脑上登录 Expo CLI:

Terminal
- npx expo login

然后,在设备上打开 Expo Go,点按右上角的账号图标,并使用同一个账号登录。

若要查看 Expo CLI 当前使用的账号,请运行:

Terminal
- npx expo whoami

重新加载项目

在 Expo Go 错误界面上按 Try Again。每次 Expo Go 请求项目时,Expo CLI 都会读取你的凭据,因此在开发服务器运行期间登录即可。

如果你登录了不同的账号,请重启开发服务器。Expo CLI 会在进程运行期间缓存解析出的账号。