[Angular 5] `ng serve` works; `ng build -prod` gives ERROR in Error:[…] add a @NgModule annotation
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
Upgraded to Angular 5 then my ng-gauge component stopped working. So I started using ng-packagr; which made ng serve
—and my application—work perfectly. Unfortunately ng build -prod
doesn’t work anymore. I’ve also tried adding the --preserve-symlinks
argument.
How To Reproduce
Add ng-gauge to your dependencies, use it somewhere, now the error is reproduced.
Expected Behaviour
ng build -prod
should produce compiled minified distribution files like it did with Angular 4.
Version Information
ng-packagr: v1.5.0
node: v8.9.0
@angular: v5.0.1
rxjs: 5.5.2
zone.js: 0.8.18
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:11 (2 by maintainers)
Top Results From Across the Web
[Angular 5] `ng build --prod` gives error […] add a @NgModule ...
I am using @once/ui shared library in a project. The command ng serve works fine for me and everything works as expected. Unfortunately,...
Read more >Angular error: Please add a @NgModule annotation
You're trying to "import" a component in SomeModule . imports: [ CommonModule, SomeComponent ],. You import modules and declare components, ...
Read more >Deprecated APIs and features - Angular
The downgradeModule supports more ergonomic NgModule-based API (versus NgModule factory based API). Deprecated featureslink. This section lists all deprecated ...
Read more >Introduction to services and dependency injection - Angular
The @Injectable() decorator defines a class as a service in Angular and allows Angular to inject it into a component as a dependency....
Read more >NgModule - Angular
A template can use exported declarables from any imported module, including those from modules that are imported indirectly and re-exported. For example, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I came to ng-packagr for the same reasons. Using angular 5.0.3 and it builds the library and publishes it fine. Where I’m having problems is on the app side, where I use my library. It builds fine for testing,
ng build
, but I cannot build for productionng build --prod --aot
, I get loads of errors stating it cannot find components in my library!Library is at: https://github.com/fourctv/JS44D
The library build shows the following warnings:
And when I use it in my app, and try
ng build --prod
, I get something like this:repeated a ton of times
FYI,
ng serve
orng build
work fine and produce perfect builds! oh, and the library also works fine in NativeScript.Versions:
Hi, thanks for your report.
I consider this an angular 5 migration task. Is that right?
There will be changes and a new version for angular 5 … “soon” like next week or in two weeks time. I’m asking to be patient for that.
Do you have a GitHub repo or similar with the sources? I am also trying to understand what is not working …
Cheers, David