【问题标题】:EXPO - connect ECONNREFUSED - Connecting to Metro bundler failedEXPO - 连接 ECONNREFUSED - 连接到 Metro 捆绑器失败
【发布时间】:2020-08-15 18:34:28
【问题描述】:

这个问题困扰我很久了,我看到很多人在这里问同样的问题,尝试了所有方法但还是不行。

我试过卸载node、expo-cli、删除.expo、关闭所有本地端口,但是一直显示这个错误。这是错误的完整日志: 附言。我使用的是 Mac,之前安装过 Flutter,不知道会不会导致错误。

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.13.4
3 info using node@v12.14.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 info lifecycle @~start: @
7 verbose lifecycle @~start: unsafe-perm in lifecycle true
8 verbose lifecycle @~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/lucas/Desktop/Coding/ReactNative/Project/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/lucas/Desktop/flutter/flutter/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/lucas/.npm-global/bin:/Users/lucas/.npm-global/bin
9 verbose lifecycle @~start: CWD: /Users/lucas/Desktop/Coding/ReactNative/Project
10 silly lifecycle @~start: Args: [ '-c', 'expo start' ]
11 silly lifecycle @~start: Returned: code: 1  signal: null
12 info lifecycle @~start: Failed to exec start script
13 verbose stack Error: @ start: `expo start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:223:5)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:223:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid @
15 verbose cwd /Users/lucas/Desktop/Coding/ReactNative/Project
16 verbose Darwin 18.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v12.14.1
19 verbose npm  v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error @ start: `expo start`
22 error Exit status 1
23 error Failed at the @ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

当我输入我的本地主机时,它会显示正常的 Metro 页面,但大约 5 秒后页面变黑并显示消息 Connecting to Metro bundler failed.

有人知道怎么解决吗?

【问题讨论】:

    标签: reactjs react-native expo


    【解决方案1】:

    我不知道这个帖子是否仍然打开,但我遇到了类似的问题,我通过几个简单的步骤解决了它:

    1. 您可以剪切 .expo 文件并将其粘贴到任何其他虚拟文件中 应用程序目录中不存在文件。
    2. 然后在重新定位 .expo 文件夹后,重新打开终端,然后执行 npm start 和之前一样。

    正如你在第 23 行看到的那样,它说这不是 npm 的问题,所以它是 卸载并重新安装 Nodejs 和 npm 是不合逻辑的。该行进一步表示还有额外的日志输出,主要是指 .expo 文件。还要检查您的互联网连接是否正常和稳定。当我从移动热点切换到 wifi 时,它确实对我有用。

    【讨论】:

      猜你喜欢
      • 2021-08-19
      • 2013-08-22
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 2017-05-16
      • 2020-08-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多