升级到 Dart2/Angular5 导入时出错 template.dart
Upgrading to Dart2/Angular5 Error importing template.dart
我正在将我的 dart/angular 项目升级到 dart 2。x/angular 5.x。 phpstorm 中的示例有效,但是当我构建我的项目时,出现以下错误:
[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分析没有显示任何错误
这是我的一些文件:
main.dart
import 'package:angular/angular.dart';
import 'package:mfgapp/app_component.template.dart' as ng;
void main() {
runApp(ng.AppComponentNgFactory);
}
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:
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 cannot be imported.
错误
问题是 layout.scss.css 的 styleUrl。在 mac pub/webdev 上没有显示任何错误,但在我的 windows machine 上我收到以下错误:
[SEVERE] build_web_compilers|entrypoint on web/main.dart:
Dart2Js finished with:
packages/angular_components/src/components/app_layout/layout.scss.css.shim.dart:
Error: Error reading 'packages/angular_components/src/components/app_layout/layout.scss.css.shim.dart' (The system cannot find the path specified.
)
Error: Compilation failed.
已更新app_component.dart:
import 'package:angular/angular.dart';
@Component(
selector: 'mfgapp',
styleUrls: ['package:angular_components/app_layout/layout.scss.css', 'layout.css', 'app_component.css'],
templateUrl: 'app_component.html',
)
class AppComponent {
}
我也遇到同样的问题。清理项目解决了这个问题。
pub cache repair
我正在将我的 dart/angular 项目升级到 dart 2。x/angular 5.x。 phpstorm 中的示例有效,但是当我构建我的项目时,出现以下错误:
[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分析没有显示任何错误
这是我的一些文件:
main.dart
import 'package:angular/angular.dart';
import 'package:mfgapp/app_component.template.dart' as ng;
void main() {
runApp(ng.AppComponentNgFactory);
}
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:
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 cannot be imported.
错误问题是 layout.scss.css 的 styleUrl。在 mac pub/webdev 上没有显示任何错误,但在我的 windows machine 上我收到以下错误:
[SEVERE] build_web_compilers|entrypoint on web/main.dart:
Dart2Js finished with:
packages/angular_components/src/components/app_layout/layout.scss.css.shim.dart:
Error: Error reading 'packages/angular_components/src/components/app_layout/layout.scss.css.shim.dart' (The system cannot find the path specified.
)
Error: Compilation failed.
已更新app_component.dart:
import 'package:angular/angular.dart';
@Component(
selector: 'mfgapp',
styleUrls: ['package:angular_components/app_layout/layout.scss.css', 'layout.css', 'app_component.css'],
templateUrl: 'app_component.html',
)
class AppComponent {
}
我也遇到同样的问题。清理项目解决了这个问题。
pub cache repair