首页 > 解决方案 > 为什么命令 expo start 不起作用?

问题描述

我正在尝试使用 nodejs 提示符打开我的 expo 项目,但我不断收到以下错误:

C:\Users\Regis\ProjetoFerias>expo start
Starting project at C:\Users\Regis\ProjetoFerias
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Could not get status from Metro bundler. connect ECONNREFUSED 127.0.0.1:19001
Connecting to Metro bundler failed.
Error: Connecting to Metro bundler failed.
    at _waitForRunningAsync (C:\@expo\xdl@59.0.10\src\Project.ts:1264:11)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at startReactNativeServerAsync (C:\@expo\xdl@59.0.10\src\Project.ts:1608:3)
    at Object.startAsync (C:\@expo\xdl@59.0.10\src\Project.ts:1785:5)
    at action (C:\Users\Regis\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:167:3)
    at C:\Users\Regis\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:334:16
    at Command.<anonymous> (C:\Users\Regis\AppData\Roaming\npm\node_modules\expocli\src\exp.ts:346:7)

我尝试使用命令“expo start -c”来清理缓存,但没有成功的结果:

C:\Users\Regis\ProjetoFerias>expo start -c
Starting project at C:\Users\Regis\ProjetoFerias
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Could not get status from Metro bundler. connect ECONNREFUSED 127.0.0.1:19001
Connecting to Metro bundler failed.
Error: Connecting to Metro bundler failed.
    at _waitForRunningAsync (C:\@expo\xdl@59.0.10\src\Project.ts:1264:11)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at startReactNativeServerAsync (C:\@expo\xdl@59.0.10\src\Project.ts:1608:3)
    at Object.startAsync (C:\@expo\xdl@59.0.10\src\Project.ts:1785:5)
    at action (C:\Users\Regis\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:167:3)
    at C:\Users\Regis\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:334:16
    at Command.<anonymous> (C:\Users\Regis\AppData\Roaming\npm\node_modules\expocli\src\exp.ts:346:7)

如您所见,出现了相同的错误(连接到 Metro bundler 失败)。

我真的不明白为什么会这样。昨天项目上的一切都正常工作,但是今天我什至无法打开应用程序。

标签: node.jsreactjsreact-nativeexpoprompt

解决方案


我发现的解决方法是运行

npm clean --force

先运行后运行

expo start -c

同样在错误开始后不久,我点击了“在网络浏览器中运行”这个解决方法避免了我自己的上述崩溃。


推荐阅读