Skip to content

AOT Giving Generic Error Message when Component is declared in multiple modules #8860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
deebloo opened this issue Dec 13, 2017 · 8 comments
Closed

Comments

@deebloo
Copy link
Contributor

deebloo commented Dec 13, 2017

When serving a generated app with AOT enabled some errors are obfuscated behind a misleading error message at build time. This issue is specifically for the same declaration in multiple modules but I believe it happens for others as well but this is the one I have an example for.

Versions

Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.0
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
@schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0

Repro steps

  • clone repo
  • run npm start (command updated with --aot)
  • see error message

Observed behavior

non specific error message shown in terminal:

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/app.module.ngfactory' in '/Users/dannyblue/Documents/projects/error-example/src'
resolve './app/app.module.ngfactory' in '/Users/dannyblue/Documents/projects/error-example/src'
  using description file: /Users/dannyblue/Documents/projects/error-example/package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/dannyblue/Documents/projects/error-example/package.json (relative path: ./src)
    using description file: /Users/dannyblue/Documents/projects/error-example/package.json (relative path: ./src/app/app.module.ngfactory)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Users/dannyblue/Documents/projects/error-example/src/app/app.module.ngfactory doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        /Users/dannyblue/Documents/projects/error-example/src/app/app.module.ngfactory.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Users/dannyblue/Documents/projects/error-example/src/app/app.module.ngfactory.js doesn't exist
      as directory
        /Users/dannyblue/Documents/projects/error-example/src/app/app.module.ngfactory doesn't exist
[/Users/dannyblue/Documents/projects/error-example/src/app/app.module.ngfactory]
[/Users/dannyblue/Documents/projects/error-example/src/app/app.module.ngfactory.ts]
[/Users/dannyblue/Documents/projects/error-example/src/app/app.module.ngfactory.js]
[/Users/dannyblue/Documents/projects/error-example/src/app/app.module.ngfactory]
 @ ./src/main.ts 3:0-66
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Desired behavior

Terminal should display the correct error message.
In the example above the expected error message is. (This is what is shown in JIT mode)

Uncaught Error: Type ExampleComponent is part of the declarations of 2 modules: ExampleModule and AppModule! Please consider moving ExampleComponent to a higher module that imports ExampleModule and AppModule. You can also create a new NgModule that exports and includes ExampleComponent then import that NgModule in ExampleModule and AppModule.
@deebloo
Copy link
Contributor Author

deebloo commented Dec 14, 2017

this may be an angular core issue and not a cli issue as referenced. here angular/angular#20292 and #8036 (comment)

@Sky4CE
Copy link

Sky4CE commented Dec 14, 2017

@deebloo , have you tried Angular v5.1.1 ? Similar issue was fixed in v5.1.1

@filipesilva
Copy link
Contributor

@PascalPrecht this looks a lot like what we were talking about yesterday. Maybe this is the real issue you are getting?

@deebloo
Copy link
Contributor Author

deebloo commented Dec 14, 2017

@Sky4CE I have not. will try now

@deebloo
Copy link
Contributor Author

deebloo commented Dec 14, 2017

@Sky4CE @filipesilva updating to 5.1.1 fixed it. I am now seeing the correct error message

@filipesilva
Copy link
Contributor

angular/angular@6727336 seems to be the commit that fixes it.

@shoagraw
Copy link

I am facing this same issue
.module.ngfactory.ts doesn't exist
.js Field 'browser' doesn't contain a valid alias configuration
and seen these comments,

it seems like this line in packate.json
"@angular/compiler-cli": "^5.0.0",
need to be updated as
"@angular/compiler-cli": "^5.1.1",

and install it.

Please confirm.

thanks,
Shobhit

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants