【问题标题】:pub build failed for dart project after using mirrors使用镜像后,dart 项目的 pub 构建失败
【发布时间】:2015-07-15 13:36:36
【问题描述】:

我依靠mythz 对Add JSON serializer to every model class? 的回答制作了一个可用于JSON 的非常简单的对象,并且当我运行它时它运行良好。但后来我意识到我什至不需要那个对象并删除了我添加的所有代码,包括 dart:mirrors 的导入。

然后我尝试再次运行我的 Dart webapp,即使主页立即出现,ChromeDevEditor 仍然显示“Building main.dart”。这和往常一样,但这次花了更长的时间,所以我尝试点击应该调用函数的东西。没用。 我关闭了 chrome 和 ChromeDevEditor 并再次重新启动它。现在它没有显示任何东西。

webapp 仍然无法运行,所以我在 Windows 资源管理器中打开了该文件夹,Shift+右键单击以打开该目录中的 CMD 并运行 pub build。因为这只会导致错误(我将在本段之后插入)我尝试运行pub get,然后是另一个pub build。根本没有帮助。 这里是非详细 pub 构建的输出:

F:\Files\Programmieren\Dart\ChromeIDE\MyNewDartTry>pub build > nonverboseerror.t
xt
Build error:
Transform ScriptInlining on MyNewDartTry|web/index.html threw error: Could not f
ind asset browser|lib/dart.js.
null
null
[Error from Dart2JS on MyNewDartTry|web/main.dart]:
packages\route_hierarchical\client.dart:11:8:
Can't read 'package:logging/logging.dart' (Could not find asset logging|lib/logg
ing.dart.).
import 'package:logging/logging.dart';
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Dart2JS on MyNewDartTry|web/main.dart]:
1 warning(s) suppressed in package:route_hierarchical.
Build failed.

但我没有弄乱包裹...... 谷歌搜索显示this link 看起来与我的错误消息有些相似。也许答案与那个链接有关,也许不是。但是在那个链接上,alan-knight 说了以下内容:

这看起来像镜像系统创建没有给出 包根。您需要两个,一个用于 VM,以便它知道 包是,并且在创建时在代码中使用的包 镜像系统。

我想知道这对我来说意味着什么,因为我不再使用那个镜像事物代码,并且我没有在添加和删除该代码之间进行其他更改。 也许我不应该复制粘贴我没有完全理解的代码......

有什么想法吗?

编辑 我在 pubspec.yaml 的依赖项中没有指定包 logging/logging.dart,但添加它并运行 pub get 没有帮助。酒吧说“有依赖关系!”就是这样。我的 route_hierarchical 可能需要该包,因此已经在 pubs 列表中获取。

pub cache repair说它重新激活了1个包并修复了问题。非常感谢 Günter Zöchbauer :) 你介意把这个作为答案吗?

【问题讨论】:

  • 看来您需要运行 pub cache repair 来解决锁定包的问题。我假设logging 是您的pubspec.yaml 中的一个依赖项,而您确实运行了pub getpub upgrade。顺便说一句,您的链接 this link 已损坏。至少在开始时缺少h,但随后它会显示 Google 搜索结果,而不是结果中的特定页面。
  • 非常感谢 :) 我修复了链接。 logging 是来自 route_hierarchical 的传输依赖。您介意发布pub cache repair作为答案吗?顺便提一句。你知道我在哪里可以找到所有的 pub 命令吗? pub help 不包含pub cache repair

标签: json dart dart-mirrors


【解决方案1】:

pub cache repair 应该可以解决您的日志记录包问题。

pub help 在可用命令下显示cache
pub help cache 在可用子命令下显示repair

https://www.dartlang.org/tools/pub/cmd/ 上查找有关pub 的更多信息

【讨论】:

    猜你喜欢
    • 2022-01-02
    • 1970-01-01
    • 1970-01-01
    • 2019-10-16
    • 2012-12-28
    • 2020-07-15
    • 2013-12-29
    • 2012-10-02
    相关资源
    最近更新 更多