Skip to content
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

Unexpected value 'ChartistModule' imported by the module 'AppModule'. Please add a @NgModule annotation. #124

Closed
ddamko opened this issue May 24, 2017 · 10 comments

Comments

@ddamko
Copy link

ddamko commented May 24, 2017

I have an Angular 4 / Electron application and I am getting the following error when importing the ChartistMoudule.

Uncaught Error: Unexpected value 'ChartistModule' imported by the module 'AppModule'. Please add a @NgModule annotation.

This seems to be an issue with how dependencies are annotated in the package.json of the library. See the Angular repo thread #15763. Has there been any testing with this module in Angular 4?

@willsoto
Copy link
Owner

Yeah, I have tests that seem to work. Also, I do have an @NgModule annotation here

@ddamko
Copy link
Author

ddamko commented May 25, 2017

When I install ng-chartist in a new angular-cli 4 app and add the module to the AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { ChartistModule } from 'ng-chartist';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    ChartistModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

ng serve

ERROR in ChartistModule is not an NgModule
webpack: Failed to compile.

@mikerhyssmith
Copy link

Hi, I also have an angular 4 app not using the CLI which throws the same error.

@reegodev
Copy link

reegodev commented Jun 1, 2017

Have the same issue, i forked the module and rebuilt it and now it works.
The dist folder of the npm package is missing a chartist.component.metadata.json file.
Its contents are

[{"__symbolic":"module","version":3,"metadata":{"ChartEvent":{"__symbolic":"interface"},"ChartistComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"x-chartist","template":"<ng-content></ng-content>"}]}],"members":{"data":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"type":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"responsiveOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"events":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"renderChart":[{"__symbolic":"method"}],"update":[{"__symbolic":"method"}],"bindEvents":[{"__symbolic":"method"}]}},"ChartistModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ChartistComponent"}],"exports":[{"__symbolic":"reference","name":"ChartistComponent"}]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"ChartEvent":{"__symbolic":"interface"},"ChartistComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"x-chartist","template":"<ng-content></ng-content>"}]}],"members":{"data":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"type":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"responsiveOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"events":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"renderChart":[{"__symbolic":"method"}],"update":[{"__symbolic":"method"}],"bindEvents":[{"__symbolic":"method"}]}},"ChartistModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ChartistComponent"}],"exports":[{"__symbolic":"reference","name":"ChartistComponent"}]}]}]}}}]

@mikerhyssmith
Copy link

Would adding a PR to make ng-chartist include AOT metadata files be welcome ?

@willsoto
Copy link
Owner

willsoto commented Jun 2, 2017

That would be fine, but it needs to be reproducible. As of now, I cannot locally generate the metadata. If a PR is made, I'd like to see instructions on how to generate it, or just fix the build if there is an issue with it.

@mikerhyssmith
Copy link

Is that a reproduction of the issue or a reproduction of how to generate the metadata ?

@willsoto
Copy link
Owner

willsoto commented Jun 2, 2017

Reproduction on how to generate the metadata.

@mikerhyssmith
Copy link

master...mikerhyssmith:master the task build:dist:aot with the changes to the tsconfig produces the metadata.json file along with what is already generated. However, I had to change some dependencies to get this running on windows as git-scripts doesn't support windows and there seemed to be issues with lodash types.

@willsoto
Copy link
Owner

willsoto commented Jun 2, 2017

Those changes seem straightforward enough to me. If you wanna make a PR, I can take a look tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants