Flutter: WebSocketException: Connection to ‘http://127.0.0.1:65028/zgqCYakHs18=/ws#‘ was not upgrade

在编译flutter build web的时候,发生了错误

Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead.
The compiler crashed: WebSocketException: Connection to 'http://127.0.0.1:65028/zgqCYakHs18=/ws#' was not upgraded to websocket
#0      _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1011:41)
#1      WebSocket.connect (dart:_http/websocket.dart:320:22)
#2      vmServiceConnectUri (package:vm_service/vm_service_io.dart:32:44)
#3      _currentHeapCapacity (package:compiler/src/common/ram_usage.dart:27:41)
<asynchronous suspension>
#4      currentHeapCapacityInMb (package:compiler/src/common/ram_usage.dart:38:20)
<asynchronous suspension>
#5      compile.compilationDone (package:compiler/src/dart2js.dart:1090:12)
<asynchronous suspension>
#6      main (package:compiler/src/dart2js.dart:1435:3)
<asynchronous suspension>

此时应该尝试flutter doctor
在这里插入图片描述

解决方案

~/.bash_profile里添加 export NO_PROXY=127.0.0.1,localhost,::1 然后,source ~/.bash_profile

重新flutter doctor
在这里插入图片描述

然后再去编译flutter build web --web-renderer canvaskit --release
在这里插入图片描述

等1-2分钟,就成功了

特此记录一下,找了我好久好久的问题!!!

猜你喜欢

转载自blog.csdn.net/u013538542/article/details/129679367