'pub get' gives an error for Angular2 pack

2019-08-11 19:33发布

问题:

I have a 'pubspec.yaml' with below content:

# #docregion
name: angular2_tour_of_heroes
version: 0.0.1
environment:
  sdk: '>=1.13.0 <2.0.0'
dependencies:
  angular2: 2.0.0-beta.15
  browser: ^0.10.0
  dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
    platform_directives:
    - package:angular2/common.dart#COMMON_DIRECTIVES
    platform_pipes:
     - package:angular2/common.dart#COMMON_PIPES
    entry_points: web/main.dart

When I run 'pub get' in command line, get below error:

Resolving dependencies... 
Got dependencies!
Precompiling dependencies... 
Loading source assets... 
Loading angular2/transform/codegen, dart_to_js_script_rewriter, observe and smokLoading angular2/transform/codegen, dart_to_js_script_rewriter, observe and smokLoading angular2/transform/codegen, dart_to_js_script_rewriter, observe and smoke/src/default_transformer transformers... 
Transformer library "package:angular2/transform/codegen.dart" not found.

How do I fix it?

Create bug report: https://github.com/dart-lang/pub/issues/1406

回答1:

I had the same issue and spent a ton of time trying to fix it. My root cause was after I migrated to a new computer. My hosts file did not migrate. Once I added 127.0.0.1 localhost to my hosts file it started working.



标签: dart angular