angular: Angular 6 upgrade: ERROR in No NgModule metadata found for 'AppModule'
I’m submitting a…
[x] Bug report
Current behavior
We upgraded our Angular 5 apps to Angular 6. While building works fine for all Linux and macOS users, our Windows users run into
ERROR in No NgModule metadata found for ‘AppModule’
when running ng build
. However, ng build --aot
works fine.
Expected behavior
ng build
should work even without --aot
on all platforms.
Minimal reproduction of the problem with instructions
Unfortunately, I cannot produce a repository that reproduces the issue. I realize that this is less than ideal, but I’m happy to debug our app if there are any ideas as to what to look into. Sadly, running ng build --verbose
only shows the same error twice instead of once.
What is the motivation / use case for changing the behavior?
We want to build our app 😃
Environment
Angular version: 6.0.3
Browser:
- [x] All browsers (or none, since the build is failing)
For Tooling issues:
- Node version: 9.11.1
- Platform: Windows (Linux & macOS work!)
Others:
- This happens only for Windows users as far as we can tell for now.
- Related: https://github.com/angular/angular-cli/issues/10516, but opening here since the error message comes from angular itself, not from the CLI.
- I looked through existing issues but couldn’t find anything helpful and certainly nothing mentioning the specificness to Windows.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 11
- Comments: 34 (11 by maintainers)
😊
This error is displayed when there’s a template compilation error or a node_module library issue, but somehow the
angular-cli
process can’t caught it and display it, so in order to see what is going on just run theng build --prod
command and it will display whatever error you have.After fixing the errors you won’t see that message again.
@michahell The link in your answer contains the solution indeed (for me). Maybe it is good to mention that the answer that did it for me was by https://stackoverflow.com/users/516708/bahri-gungor and not the selected answer. I quote his answer her:
degrootsde answer solved my issue as well. I have no idea why rearranging
“include”: [“src//.ts","node_modules/angular-bootstrap-md//.ts” ], solved the problem. But am happy I didn’t need to debug it too long. Other way I found of solving this was to add a blank line to app.module.ts and save the file while ng serve was running, this seemed to be temporary an next time I started ng serve I would have to do the same again. It all seems a little strange . I am also an angular-bootstrap-md and windows user running in vscode.
We fixed this by either moving main.ts to be the first entry in the “include” array in tsconfig.app.json or adding a “files” array containing main.ts. We bumped into this error in quite a few projects.
There was no additional error messages to go by - we saw this error a few times too, but accompanied by other errors. In those cases , it was mostly caused by actual errors in using rxjs functions. Once those were fixed and the error persisted, this was what needed to be done.
I got past this problem by
not declaring platformBrowserDynamic
as mentioned here: https://stackoverflow.com/questions/39685179/angular-2-no-ngmodule-metadata-foundwhich to me, totally makes zero sense 😬 👍
This issue seems abandoned without any reproducible instruction. We are closing the issue. If you have reproducible instructions please file a new issue.
@Airblader Did you force cache clean ? I had the same problem few weeks ago and it was related to Angular-CLI. Try to remove Angular-CLI globally first, remove node_modules, then run
npm cache clear --force
,npm cache verify
, install latest version of Angular-CLI globally and finally runnpm install
Edit: I’m also Windows user