expo ios 模拟器 'could not connect to development server' 错误(在浏览器上工作)

expo ios simulator 'could not connect to development server' error(works on browser)

我在实践中使用react-native expo开发一个聊天应用程序,但是当我在通常的开发流程中突然执行“expo start”时,显示“无法连接到开发服务器”的错误。

如果您也遇到过同样的错误并且知道解决方法,希望能帮到您。

因为之前是用aws-amplify链接的,我以为是那个关系安装的那个是错误的原因,但是由于应用程序在浏览器中正常启动,只有iOS模拟器不工作(Android出现无限下载不启动的情况)

我试过的

1)用expo start -c

删除缓存

2)如错误所说,重复npm start然后reload。

3)用kill命令删除19000,以为是端口问题。 · npm 安装 ・ rm -rf node_modules / && rm -rf yarn_lock / && yarn install && cd ios && pod install

没有任何效果,我想不出任何解决它的好主意。研究中的所有解决方案均失败。我还能做什么?

引用链接

Could not connect to the development server react native ios simulator Node

package.json↓

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "test": "jest --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "-": "^0.0.1",
    "@expo/vector-icons": "^12.0.0",
    "@react-native-async-storage/async-storage": "^1.15.11",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/netinfo": "^6.2.1",
    "@react-navigation/bottom-tabs": "5.11.2",
    "@react-navigation/native": "~5.8.10",
    "@react-navigation/stack": "~5.12.8",
    "aws-amplify": "^4.3.6",
    "aws-amplify-react-native": "^6.0.1",
    "cli": "^1.0.1",
    "expo": "~42.0.1",
    "expo-asset": "~8.3.2",
    "expo-constants": "~11.0.1",
    "expo-font": "~9.2.1",
    "expo-linking": "~2.3.1",
    "expo-splash-screen": "~0.11.2",
    "expo-status-bar": "~1.0.4",
    "expo-web-browser": "~9.2.0",
    "g": "^2.0.1",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-reanimated": "~2.2.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.4.0",
    "react-native-web": "~0.13.12"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@types/react": "~17.0.21",
    "@types/react-native": "~0.64.12",
    "jest-expo": "~41.0.0-beta.0",
    "typescript": "~4.3.5"
  },
  "private": true
}

我在使用 amplify 时遇到了完全相同的问题。

首先,不仅要看 expo 控制台,还要看终端。

如果终端说你的项目中有重复的文件,删除其中一个,并清除所有缓存并通过 expo start -c 命令重新启动。

我猜这个问题是因为 amplify 比我们聪明,所以他们会自动创建备份文件等,而 expo 将它们误认为是重复的。

但是,包括删除缓存在内,这种方式有效,所以我不是100%确定。

如果解决了,我会很高兴。