Angular: Compile issue: Unable to find module for angular

Created on 29 Dec 2017  路  6Comments  路  Source: angulardart/angular

There is a problem when try build or serve angular 5.0.0-alpha+2 project on Windows.

Serving soy_angular web on http://localhost:8080
Build completed successfully
[web] GET Served 2 cached assets.
Unable to find module for angular|lib/src/bootstrap/..%5Cplatform%5Cbrowser%5Cexceptions.dart
Unable to find module for angular|lib/src/bootstrap/..%5Cplatform%5Cbrowser%5Cexceptions.dart
Unable to find module for angular|lib/src/bootstrap/..%5Cplatform%5Cbrowser%5Cexceptions.dart
[web] GET main.dart.js => Could not find asset soy_angular|web/main.dart.js.

pubspec.yaml

name: soy_angular
description: test example.
version: 1.0.0

environment:
  sdk: '>=2.0.0-dev.3.0 <2.0.0'

dependencies:
  angular: '^5.0.0-alpha+2'
  angular_forms: '^1.0.1-alpha+2'
  angular_router: '^2.0.0-alpha+2'

dependency_overrides:
  analyzer: ^0.31.0-alpha.1

transformers:
  - angular:
      entry_points:
          - web/main.dart
          - test/**_test.dart

web:
  compiler:
    debug: dartdevc

main.dart

import 'package:angular/angular.dart';
import 'package:soy_angular/app.component.dart';

// ignore: uri_has_not_been_generated
import 'main.template.dart' as ng;

void main() {
  bootstrapStatic<AppComponent>(
      AppComponent, <dynamic>[], ng.initReflector as Function);
  // bootstrapFactory(ng.AppComponentNgFactory);
}

Same problem https://github.com/dart-lang/angular/issues/723

compiler bug

All 6 comments

I took another stab at this today and modified the angular compiler to fix this for me. I'm not really sure if this would be a proper solution, though.

The offending line appears to be here: https://github.com/dart-lang/angular/blob/f3b7d89ed82261f7e0b534223147c81a515187b3/angular_compiler/lib/src/analyzer/di/injector.dart#L83

As per the documentation, path (which on windows will contain \) will be url encoded. I fixed this locally for me by replacing it with this:

return referTo(new Uri(pathSegments: p.split(relativePath), fragment: to.fragment));

which will only url encode the individual path segments

@ligustah: I patched injector.dart at "C:\Users\HBE\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\angular_compiler-0.4.0-alpha+2\lib\src\analyzer\di\injector.dart", but compilation still fails in my case (see https://github.com/dart-lang/angular_components_example/issues/52).

You might need to remove your .pub folder for it to actually recompile everything

@ligustah Thanks for the pointer, deleting the .pub cache folder from the project root solved the issue for me and everything compiles now just fine. So your patch is working 馃憤

Thank you @nekrondev - I'll get this patched.

Good news: This looks fixed in +4, which is yet to be published. We'll do this week.

Was this page helpful?
0 / 5 - 0 ratings