angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

JIT mode only: Uncaught Error: Unexpected value imported by the module 'AppModule'. Please add a annotation.

Open anjmao opened this issue 9 years ago • 27 comments

Bug 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 [email protected]: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 :)

anjmao avatar Aug 17 '17 13:08 anjmao

I had the same problem with a linked lib for angular 5 and this worked for me: https://stackoverflow.com/a/47445313/1438483

ghost avatar Dec 01 '17 13:12 ghost

@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

MatSnackBarModule

in the app module and MatSnackBar in the component the error resolved..

jaganpon avatar Dec 08 '17 09:12 jaganpon

screen shot 2017-12-30 at 9 40 32 pm As of 12-30-17 , MatSnackBar is still being advertised on the material.angular site https://material.angular.io/components/snack-bar/overview Not the correct MatSnackBarModule, I wonder why?

MarvelMoe avatar Dec 31 '17 05:12 MarvelMoe

"compiler.js:15975 Uncaught Error: Unexpected value 'AngularFireDatabase' imported by the module 'AppModule'. Please add a @NgModule annotation." I got this error when I trying to save data in firebase real-time database using the AngularFirebaseDatabase module.

himharsh1997 avatar Apr 12 '18 09:04 himharsh1997

Are you still able to reproduce this issue?

mgechev avatar Dec 18 '18 23:12 mgechev

Closing the issue due to inactivity. If the problem still exists in the latest version of the CLI, please open a new issue following the template and providing a minimal demo where we can reproduce it. Thanks! :-)

mgechev avatar Dec 21 '18 22:12 mgechev

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.