-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Angular 5 Error: Unexpected value 't' imported by the module 't'. Please add a @NgModule annotation #20815
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
Comments
Hi! I'm afraid that we will need some sort of a minimal reproduce scenario to move forward on this one. |
Hi @MrHOY |
Opps... Hope angular cli team can fix it. |
This ticket appears to be closed. Can someone post a fix? I am still getting the error. Uncaught Error: Unexpected value 't' imported by the module 'function (){}'. Please add a @NgModule annotation. |
@rpeddu I'm not sure but when I update my package, I not see this error, you can try it
|
I have the same issue. Can anyone post a fix pls? |
Same Here, I am building with |
I am having the same issue. Disabling the mangle option in my production webpack configuration for the UglifyJs plugin reveals this error:
Can someone from the Angular CLI team please help. This is very frustrating!! I know that this particular issue did not occur for me with previous app projects using Angular CLI version 4.4.3. @pkozlowski-opensource To reproduce clone the angular-starter repo here: https://github.com/gdi2290/angular-starter Install npm modules then run the production webpack configuration. At the moment I am achieving this with:
I have setup a local web site through IIS pointing to the dist subfolder. This is the console error I see when I browse that site (I have also attached a screen grab):
You can achieve the same with:
FYI I have tried updating all my Angular packages to the latest version (5.2.2) but this error still persists. |
Just in case anyone else is having this same issue I managed to work around this issue with the help of this Angular bug fix: Also see: The fix is to not use the buildOptimizer for JIT in production builds. For my project specifically because it is based on the angular starter repo here: https://github.com/gdi2290/angular-starter (@gdi2290 please note) the fix was changing config\build-utils.js @ line 78 From:
To:
And just to be tidy I removed the now redundant AOT check @ line 109 From:
To:
Anyway hope this helps because I have wasted a lot of time on this. |
Update: Found out that there is already a pull request for the angular starter repo (https://github.com/gdi2290/angular-starter) with exactly the same changes as I came up with above here: https://github.com/gdi2290/angular-starter/pull/1950/files |
@graemehyde works for me. thank you |
I had the same issue and I change ng build --prod aot=false to ng build --prod --build-optimizer=false" |
Hi folks.. |
This was my solution.
ng build --prod --build-optimizer=false
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
…________________________________
From: sohanyugasa <[email protected]>
Sent: Saturday, April 28, 2018 3:30:59 AM
To: angular/angular
Cc: Miguel Peguero; Comment
Subject: Re: [angular/angular] Angular 5 Error: Unexpected value 't' imported by the module 't'. Please add a @NgModule annotation (#20815)
Hi folks..
Same issue I am facing. Anyone let me know what is the best solution for this one.
Uncaught Error: Unexpected value 'HttpClient' imported by the module 'AppModule'. Please add a @NgModule<https://github.com/NgModule> annotation.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#20815 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABvDp9VumXxuUQo8OCiHqUFnVmsHmE2Hks5ttBqzgaJpZM4Q3gTU>.
|
compiler.js:486 Uncaught Error: Unexpected value 'AngularFireStorage' imported by the module 'AppModule'. Please add a @NgModule annotation. Package.json app.module.ts @NgModule({ i am getting this error , can anyone please suggest a solution. |
@mpeguero I am facing same issue but we are not using angular-cli in our project so i am not able to use given command Could you please tell me how to resolve this issue without angular-CLI. Is there any way to change buildOptimizer property.I am new to angular.Your help is highly appericiated |
My problem was I had reference in my provider that was not a provider. Check yours references on the ngModule.
…Sent from my iPhone
On Aug 11, 2018, at 6:46 AM, DnyaneshwarShivbhakta <[email protected]<mailto:[email protected]>> wrote:
@mpeguero<https://github.com/mpeguero> I am facing same issue but we are not using angular-cli in our project so i am not able to use given command Could you please tell me how to resolve this issue without angular-CLI. Is there any way to change buildOptimizer property.I am new to angular.Your help is highly appericiated
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#20815 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABvDp_FMZ6wleMuWA4GmKS_gGu9gj8seks5uPrYLgaJpZM4Q3gTU>.
|
@mpeguero I am migrating existing angular 2 application to angular 4.In angular 2 its working fine but after migration, I'm getting this error. I don't know what to do from last week I am clueless about this error. |
I was doing the same. Upgrading v2 to 4
…Sent from my iPhone
On Aug 11, 2018, at 12:37 PM, DnyaneshwarShivbhakta <[email protected]<mailto:[email protected]>> wrote:
@mpeguero<https://github.com/mpeguero> I am migrating existing angular 2 application to angular 4 at that time I'm getting this error.I don't know what to do from last week I am clueless on this error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#20815 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABvDp88nmf940v1XK6mbTIDyoUWnmY18ks5uPwgvgaJpZM4Q3gTU>.
|
@mpeguero I tried removing every provider by commenting one by one but no luck. I don't know what is this issue. This issue frustrates me a lot. |
If you are using a child library, kindly update the import there to . Eg : import { TranslateService } from '@ngx-translate/core'; @NgModule({ child.module.ts import { TranslateService } from '@ngx-translate/core'; @NgModule({ |
@tigersharma Thanks for your valuable support but my Issue was different. I was facing an issue in ng2-color-picker package.I replaced that package with ngx-color-picker and my issue gets resolved :) |
Import HttpClientModule not HttpClient in appmodule |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When I run 'ng serve', my app work well.

But when I run 'ng build' and test by run 'http-server dist/ -o' my app not running with error:
I'm submitting a...
Environment
The text was updated successfully, but these errors were encountered: