JIT mode only: Uncaught Error: Unexpected value imported by the module 'AppModule'. Please add a annotation.
See original GitHub issueBug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.3.0
node: 6.11.0
npm: 5.3.0
os: darwin x64
@angular/animations: 4.3.5
@angular/common: 4.3.5
@angular/compiler: 4.3.5
@angular/core: 4.3.5
@angular/forms: 4.3.5
@angular/http: 4.3.5
@angular/platform-browser: 4.3.5
@angular/platform-browser-dynamic: 4.3.5
@angular/router: 4.3.5
@angular/cli: 1.3.0
@angular/compiler-cli: 4.3.5
@angular/language-service: 4.3.5
Repro steps.
Repository https://github.com/ng-select/ng-select
git clone git@github.com:ng-select/ng-select.git
cd ng-select
npm install
npm run build // should output dist folder
cd integration
npm install // should install @ng-select/ng-select from dist folder
ng serve // will file at runtime
ng serve --prod // works fine
The log given by the failure.
Uncaught Error: Unexpected value 'NgSelectModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (compiler.es5.js:1690)
at compiler.es5.js:15382
at Array.forEach (<anonymous>)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15365)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._loadModules (compiler.es5.js:26795)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (compiler.es5.js:26768)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (compiler.es5.js:26697)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone (core.es5.js:4536)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (core.es5.js:4522)
at Object.../../../../../src/main.ts (main.ts:11)
Desired functionality.
I expect to serve linked local library without any errors as it works with -aot mode.
Mention any other details that might be useful.
I get this error only then I’m installig local library from dist folder and only with JIT mode. In package.json I have added "@ng-select/ng-select": "../dist/"
It works perfectly fine if I install library from npm repository. I tried to add paths to tsconfig as described here https://github.com/angular/angular-cli/wiki/stories-linked-library but it doesn’t work for me. I would be very helpful if somebody can look at this issue, I thought something may be wrong with my code somewhere but I suppose everything should work fine in JIT mode if it is working in AOT mode 😃
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:27 (3 by maintainers)
Top Results From Across the Web
JIT mode only: Uncaught Error: Unexpected value imported by the ...
JIT mode only : Uncaught Error: Unexpected value imported by the module 'AppModule'. Please add a annotation.
Read more >Uncaught Error: Unexpected value '...' imported by the module ...
It wants me to add a @NgModule annotation, but I have @NgModule in both of my Modules. I don't know what I am...
Read more >Angular Modules and NgModule - Complete Guide
This happens by design: Modules that are directly imported are usually meant to enrich the importing module functionality (in this case, the ...
Read more >'formsmodule' does not appear to be an ngmodule class.
It is module that I use in a whole project that has other modules imported. Here is code with that module. @NgModule annotation...
Read more >NgModule FAQ - Angular
Add only declarable classes to an NgModule's declarations list. ... A component could be imported from another application module (so you can't declare...
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 Free
Top 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
A lot of these solutions are hacks which seem unpractical, especially when it comes to maintainability. A core/shared library is that way because it holds system critical functionality. I much rather not get used to deleting angular/core folders out of a (or many) library(ies).
I have been trying to follow yeoman’s library seed to properly build a lib (which looks somewhat similar to what @filipesilva is building) as the way to go (to take out my inexperience). But I still run into these issues as described above. It is quite frustrating.
Obviously there are many more out there that have abstracted core code into a lib. A good solution, or a fix, would be welcome. It obviously has to do with the fact that two @angular/* modules are included and therefore the app loads neither (or something like that).
Yes, I could just use 1.2.7 until there is a “golden standard”. But it would also be good to know that this is being addressed (or shown that we are all doing it wrong). So far there is no comment on this thread.
Thanks for building such an awesome tool though. It has helped a ton and is really amazing! I also understand that there are priorities (this may not be one). I don’t want to sound ungrateful.
@amivit
I got the same error Unexpected value ‘MatSnackBar’ imported by the module ‘AppModule’. Please add a @NgModule annotation. at syntaxError (webpack-internal:///…/…/…/compiler/esm5/compiler.js:684)
Just added
in the app module and MatSnackBar in the component the error resolved…