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

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

问题描述

我要将dart/angular项目升级到dart 2.x/angular5.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

我已按照指南迁移了项目,并且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

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

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天全站免登陆