angular-quickstart-lib icon indicating copy to clipboard operation
angular-quickstart-lib copied to clipboard

vendor.bundle.js:27884 Uncaught Error: Unexpected value 'MyModule' imported by the module 'AppModule'. Please add a @NgModule annotation

Open playground opened this issue 7 years ago • 5 comments

I have created a shared service and it built successfully. But when I tried to import it into my project and it throws error in the browser.

@filipesilva I'm still getting the same error Uncaught Error: Unexpected value 'ShareServiceModule' imported by the module 'AppModule'. Please add a @NgModule annotation.. My shared module is just a service with no ui component.

Shared Service Module

import { ShareService } from './service/share.service';
@NgModule({
  declarations: [],
  providers: [
    ShareService
  ],
  imports: [],
  exports: []
})
export class ShareServiceModule { }

Local Module

import { ShareServiceModule} from 'share-service';
@NgModule({
  imports: [ShareServiceModule]
})
export class AppModule { }

playground avatar Aug 26 '17 05:08 playground

Having the same problem! Couldn't fine any solution so far

SebastianSchenk avatar Sep 24 '17 12:09 SebastianSchenk

@SebastianSchenk I got it working, make sure you specify your moduleName under rollup:umd If you are running the latest rollup it should be "name": "you-module-name"

playground avatar Sep 24 '17 18:09 playground

any solution for this issue??

hajjem-ayoub avatar Nov 09 '17 11:11 hajjem-ayoub

The issue for me was that i was updating typescript dependancy from this seed and then i had this issue https://github.com/angular/angular/issues/20146 to give more explanation, ngc (v5) strips completely decorators if used with typescript >= 2.5 so it works fine with AOT coz they are actually not needed but not with JIT one solution that worked for me is to add to your tsconfig "annotationsAs": "decorators" but this is not good because then you re not using tsickle one other solution is to use @angular/tsc-wrapped instead of ngc directly (i think ngc is using tsc-wrapped anyway) that's not good coz the angular team advice against it for some reason the other solution that i went for is that you downgrade Typescript to "typescript": ">=2.4.2 <2.5"

and this is what i actually did

so i think this issue have nothing to do with this repo

hajjem-ayoub avatar Nov 17 '17 10:11 hajjem-ayoub

I'm having the same error. I was using typescript 2.3.0 but following @hajjem-ayoub 's suggestion I upgraded to 2.4.2. I didn't follow where I should add a name per @playground 's suggestion but I don't think I'm using the umd build.

I ran the build, then npm installed the dist folder to another local repo for testing. That other repo throws this error at runtime.

Feeling rather dejected because the reason I started using the quickstart-lib was because I got the same error when importing raw typescript through a linked repo. I thought it would go away if I imported a built es5 file instead.

rysilva avatar Jan 31 '18 18:01 rysilva