【问题标题】:Failed to compile application for the Web无法为 Web 编译应用程序
【发布时间】:2023-02-11 14:20:58
【问题描述】:

我正在尝试在网络上构建并运行一个 flutter firebase 项目,但是,我一次又一次地收到此错误。我已将我的项目添加到 firebase 并已在 index.html 文件中添加了必要的详细信息,但仍然出现错误。 这是详细的-

[   +7 ms] Done persisting file store
[   +7 ms] Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use    
'dart compile
           js' instead.

../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_messaging_web-2.4.4/lib/src/internals.dart:2:1:     
           Error: Error when reading
           '../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/internals.dart':    
Error reading
           '../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/internals.dart'     
(The system
           cannot find the file specified.
           )
           export 'package:firebase_core/src/internals.dart' hide guardWebExceptions;
           ^

../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_messaging_web-2.4.4/lib/src/internals.dart:6:8:     
           Error: Error when reading
           '../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/internals.dart':    
Error reading
           '../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/internals.dart'     
(The system
           cannot find the file specified.
           )
           import 'package:firebase_core/src/internals.dart' as internals;
                  ^

../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_messaging_web-2.4.4/lib/src/internals.dart:11:20:   
           Error: Method not found: 'guardWebExceptions'.
             return internals.guardWebExceptions(
                              ^^^^^^^^^^^^^^^^^^
           Error: Compilation failed.

[  +16 ms] Compiling lib\main.dart for the Web... (completed in 10.7s)
[   +1 ms] "flutter web" took 11,811ms.
[   +6 ms] Exception: Failed to compile application for the Web.
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>


[ +159 ms] ensureAnalyticsSent: 153ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[   +1 ms] exiting with code 1

【问题讨论】:

  • 我也有同样的问题。我不记得我做了什么更改,因为之前应用程序编译没有问题,现在它有这个错误。我会继续研究,希望有人能在这里为我们解答。
  • 你能解决这个问题吗?

标签: flutter firebase dart google-cloud-firestore flutter-web


【解决方案1】:

嘿伙计你找到解决这个错误的方法了吗? 因为我也面临完全相同的错误,所以我也需要解决方案。

/D:/WindowsSoftware/src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-2.8.8/lib/src/internals.dart:2:1: Error: Error when reading '/D:/WindowsSoftware/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/internals.dart': The system cannot find the file specified.

导出 'package:firebase_core/src/internals.dart' 隐藏 guardWebExceptions; ^ /D:/WindowsSoftware/src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-2.8.8/lib/src/internals.dart:6:8: 错误:读取时出错 '/D:/WindowsSoftware/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/internals.dart':系统找不到指定的文件。

将“package:firebase_core/src/internals.dart”导入为内部构件; ^ /D:/WindowsSoftware/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage_web-3.3.7/lib/src/utils/errors.dart:8:8: 错误:读取时出错 '/D:/WindowsSoftware/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/internals.dart':系统找不到指定的文件。

将“package:firebase_core/src/internals.dart”导入为内部构件; ^ /D:/WindowsSoftware/src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-2.8.8/lib/src/internals.dart:11:20: 错误:找不到方法:'guardWebExceptions' . 返回 internals.guardWebExceptions( ^^^^^^^^^^^^^^^^^^^ /D:/WindowsSoftware/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage_web-3.3.7/lib/src/utils/errors.dart:20:20: 错误:找不到方法:'守卫网络异常'。 返回 internals.guardWebExceptions(

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加更多详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写出好的答案的信息in the help center
【解决方案2】:

我更新了我的 Firebase 相关包并解决了类似的问题。

【讨论】:

    猜你喜欢
    • 2022-10-17
    • 2020-07-09
    • 1970-01-01
    • 2021-11-01
    • 1970-01-01
    • 2022-01-17
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多