【问题标题】:Failed to load packages - Dart Angular Tutorial加载包失败 - Dart Angular 教程
【发布时间】:2018-09-11 20:47:33
【问题描述】:

我尝试按照Angular with Dart 的教程进行操作。 在我进入导航章节之前,一切都很好。 当我使用 webstorm 和 chromium 运行项目时,我总是会收到此错误。 我也尝试运行solution repo,但我得到了同样的错误。 似乎这些包浏览器/角度等未加载。 也许webstorm有一些限制?!有趣的是它在第一次运行时偶尔会起作用,但是当我在浏览器中刷新页面时,错误总是会回来。

http://localhost:63342/toh-5-master/web/packages/browser/dart.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:63342/toh-5-master/web/packages/angular/angular.dart Failed to load resource: the server responded with a status of 404 (Not Found)
package:angular/angular.dart:1 An error occurred loading file: package:angular/angular.dart
http://localhost:63342/toh-5-master/web/packages/angular_router/angular_router.dart Failed to load resource: the server responded with a status of 404 (Not Found)
package:angular_router/angular_router.dart:1 An error occurred loading file: package:angular_router/angular_router.dart
http://localhost:63342/toh-5-master/web/packages/angular_tour_of_heroes/app_component.dart Failed to load resource: the server responded with a status of 404 (Not Found)
package:angular_tour_of_heroes/app_component.dart:1 An error occurred loading file: package:angular_tour_of_heroes/app_component.dart

编辑 上面的事情现在正在工作,因为我改成了这个 repo: github.com/angular-examples/toh-5/tree/5-dev 适用于 Dart 2。

现在我对新的 5-dev repo 有另一个问题。 这是我的酒吧服务控制台。它说 ma​​in.template.dart 丢失。 (我使用的是 Dart 版本 2.0.0-dev.44.0.

有没有人可以解决这个问题?

Compiling angular_tour_of_heroes|web/main.dart...
[web] GET styles.css => (cached) angular_tour_of_heroes|web/styles.css
[Error from Dart2JS on angular_tour_of_heroes|web/main.dart]:
file:///C:/xampp/htdocs/flutterprojects/toh-5-5-dev/web/main.template.dart: Could not find asset angular_tour_of_heroes|web/main.template.dart.
[Info from Dart2JS]:
Took 0:00:03.911463 to compile angular_tour_of_heroes|web/main.dart.
Build completed with 1 errors.
[web] GET main.dart.js => Could not find asset angular_tour_of_heroes|web/main.dart.js.
[web] GET index.html => angular_tour_of_heroes|web/index.html

当我直接使用控制台运行它时,出现以下错误。

> 发布服务 --web-compiler=dartdevc

Build completed successfully
[web] GET  => angular_tour_of_heroes|web/index.html
[web] GET styles.css => angular_tour_of_heroes|web/styles.css
Unable to find module for angular|lib/src/bootstrap/modules.template.dart
Unable to find module for angular|lib/src/bootstrap/modules.template.dart
Unable to find module for angular|lib/src/bootstrap/modules.template.dart

【问题讨论】:

    标签: dart angular-dart


    【解决方案1】:

    对于 Angular 4 示例应用

    如果您的应用程序中出现阻止 dart2js 成功编译的错误,则可能会发生此类加载失败。 WebStorm 的 Pub Serve 选项卡中是否有任何错误或警告由 pub 报告?还要确保您使用的是 1.24.3 版本的 Dart SDK

    我无法重现您提到的问题。我已经下载了项目 zip,它在命令行和 WebStorm 中运行良好(即使在进行了一些编辑和刷新之后)。请注意,第一次加载应用时,您可能会收到 404,因为 pub 可能尚未完成编译您的应用。

    对于 Angular 5 示例应用

    如您所见,如果您想尝试使用 Angular 5-alpha 的示例,请切换到 repo 的 5-dev 分支。确保您使用的 SDK 至少是 Dart 2-dev 版本。

    Dart 2 SDK 不再支持pub buildpub serve。截至 2018 年第二季度,您不能使用 WebStorm 构建和提供 Angular 5 应用程序。相反,您需要从命令行执行此操作:

    pub run build_runner serve

    然后在 Chrome 中打开localhost:8080。 有关详细信息,请参阅 Angular 5 Setup for Development

    【讨论】:

    • 我已经下载了 Dart 2.0.0-dev.42.0 并在初始帖子中发布了我的发布服务器选项卡作为编辑
    • 我总是收到页面加载器不是真实路径的错误。我查了一下这条路径“examples/util/pageloader”不存在。解决依赖关系...第 1 行第 1 列出错:缺少必需的“名称”字段。
    • 现在您已经切换到 Angular 5 示例,我已经更新了答案以涵盖该问题。我能够从示例 repo 构建和提供 5-dev toh-5 应用程序而没有任何问题。如果您仍有问题,请告诉我。
    【解决方案2】:

    Angular 5 即将推出。我可以想象 TOH 还没有完全赶上。您可以查看https://github.com/dart-lang/site-webdev.git 了解已知问题。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-16
    • 2013-02-01
    • 1970-01-01
    • 2019-07-19
    • 2011-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多