升级到 Dart2/Angular5 导入 template.dart 时出错 [英] Upgrading to Dart2/Angular5 Error importing template.dart

查看:23
本文介绍了升级到 Dart2/Angular5 导入 template.dart 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的 dart/angular 项目升级到 dart 2.x/angular 5.x.phpstorm 中的示例有效,但是当我构建我的项目时,出现以下错误:

I am upgrading my dart/angular project to dart 2.x/angular 5.x. The sample in phpstorm works, but when I build my project, then I am getting following error:

[SEVERE] build_modules|modules on lib/app_component.template.dart:

Bad state: No element
[SEVERE] build_web_compilers|entrypoint on web/main.dart:
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).

Please check the following imports:

`import 'package:mfgapp/app_component.template.dart' as ng;` from mfgapp|web/main.template.dart at 8:1
`import 'package:mfgapp/app_component.template.dart' as ng;` from mfgapp|web/main.dart at 1:1

我用guidlines迁移了项目,dart分析没有显示任何错误

I migrated the project with the guidlines, and dart analysis does not show any errors

这是我的一些文件:

main.dart
import 'package:angular/angular.dart';
import 'package:mfgapp/app_component.template.dart' as ng;

void main() {
  runApp(ng.AppComponentNgFactory);
}

app_component.dart

app_component.dart

import 'package:angular/angular.dart';


@Component(
  selector: 'mfgapp',
  styleUrls:  ['package:angular_components/src/components/app_layout/layout.scss.css', 'layout.css', 'app_component.css'],
  templateUrl: 'app_component.html',
)


class AppComponent {

}

pubspec.yaml:

pubspec.yaml:

name: mfgapp
description: A web app that uses AngularDart Components

environment:
  sdk: '>=2.0.0-dev.68.0 <3.0.0'

dependencies:
  angular: ^5.0.0-beta
  angular_components: ^0.9.0-beta

dev_dependencies:
  angular_test: ^2.0.0-beta
  build_runner: ^0.9.0
  build_test: ^0.10.2
  build_web_compilers: ^0.4.0
  test: ^1.0.0

我减少了代码以指示错误,但没有任何变化.即使我删除了 import 语句,我也会收到 app_component.template.dart as ref1 无法导入的错误.

I reduced my code to indicate the error, but there is no change. Even if I delete the import statement, I am getting error that app_component.template.dart as ref1 cannot be imported.

推荐答案

我遇到了同样的问题.清理项目解决了这个问题.

The same issue for me. Cleaning the project fixed the issue.

pub cache repair

这篇关于升级到 Dart2/Angular5 导入 template.dart 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆