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

ERROR in ChartistModule is not an NgModule #94

Closed
nikoxgon opened this issue Feb 22, 2017 · 25 comments
Closed

ERROR in ChartistModule is not an NgModule #94

nikoxgon opened this issue Feb 22, 2017 · 25 comments
Assignees
Labels

Comments

@nikoxgon
Copy link

OS?

Mac OSX El Capitan - 10.11.6 (15G1004)

Versions.

@angular/cli: 1.0.0-beta.32.3
node: 6.9.5
os: darwin x64
@angular/common: 2.4.0
@angular/compiler: 2.4.0
@angular/core: 2.4.0
@angular/forms: 2.4.0
@angular/http: 2.4.0
@angular/platform-browser: 2.4.0
@angular/platform-browser-dynamic: 2.4.0
@angular/router: 3.4.0
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.0

Chartists Versions

angular2-chartist: 0.12.1
chartist": ^0.10.1
@types/chartist: ^0.9.34

I use angular/cli and when use the command ng serve returned this error ERROR in ChartistModule is not an NgModule but, when change and save any file, livereload omitted the error and all ok.

the main problem is in production mode. when i tried use the command ng build got this

ERROR in Unexpected value 'ChartistModule in /Users/userName/mainFolder/Project/tablero/node_modules/angular2-chartist/dist/chartist.component.d.ts' imported by
the module 'AppModule in /Users/userName/mainFolder/Project/tablero/src/app/app.module.ts'

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/userName/mainFolder/Project/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

anyone can help me?. i don't know how solve this.

@willsoto
Copy link
Owner

This is probably related to the AoT changes I just made. You can use v0.11.1 until the AoT stuff gets fixed.

@willsoto willsoto added the bug label Feb 22, 2017
@willsoto willsoto self-assigned this Feb 22, 2017
@nikoxgon
Copy link
Author

i tried the version 0.11.1 and the same. i got the same error when used ng serve

ERROR in ChartistModule is not an NgModule

when use ng build --prod i got

ERROR in Unexpected value 'ChartistModule in /Users/userName/mainFolder/Project/node_modules/angular2-chartist/dist/chartist.component.d.ts' imported by
the module 'AppModule in /Users/userName/mainFolder/Project/src/app/app.module.ts'

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/userName/mainFolder/Project/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

same to version 0.12.1

@willsoto
Copy link
Owner

@nikoxgon
Copy link
Author

Thanks for fast reply. I tried to solve this problem on angular-cli. unfortunately no solution for me now. if i solve this. i reply here.

@nikoxgon
Copy link
Author

I found solution. I tested with other packages and compared to angular2-chartist I found 1 difference.

Angular-cli ver. 1.0.0-beta.32.3

Is necessary edit tsconfig.json.

see a example.

                  ...
    "module": "es2015",
    "moduleResolution": "node",
    "paths": {
      "angular2-chartist": [
        "../node_modules/angular2-chartist/src"
      ]
    },
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
                ....

we need to add this.

    "paths": {
      "angular2-chartist": [
        "../node_modules/angular2-chartist/src"
      ]
    },

Next, it is necessary edit the angular2-chartist package.

  • i tried with other packages and the solution works without edit.

First go to src directory. ./node_modules/angular2-chartist/src

Next create new file. named index.ts and add next line code in file.

export * from './chartist.component';

And everything works fine. No errors.

@willsoto
Copy link
Owner

This issue was that metadata wasn't being created by @ngtools/webpack. I am gonna revert to use the regular typescript loader until it becomes more stable. I might end up opening an issue on angular-cli once I have some time to make a detailed report.

@nikoxgon
Copy link
Author

nikoxgon commented Feb 23, 2017

I tried with version 0.12.2 and is the same problem and same solution. Nothing change.

ERROR in ChartistModule is not an NgModule with ng serve

ERROR in Unexpected value 'ChartistModule in /Users/Nico/Desktop/tableroKpi/node_modules/angular2-chartist/dist/chartist.component.d.ts' imported
by the module 'AppModule in /Users/Nico/Desktop/tableroKpi/src/app/app.module.ts'

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/Nico/Desktop/tableroKpi/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

with ng build --prod and ng build --prod --aot

@willsoto
Copy link
Owner

I think there are issues with angular-cli. You can always revert back to 0.11.1

@ricketybits
Copy link

If anyone comes here looking for solution; I found that it works if you import from src, but not if you import from dist

import { ChartistModule } from "ng-chartist/src/chartist.component"

Fixed the "ChartistModule is not an NgModule" error for me

@chaliaga
Copy link

chaliaga commented Apr 6, 2017

I suggest using: ng build --env=prod --output-hashing none and works fine

@palanibsm
Copy link

@chaliaga - Your solution works. Really awsome.

@fayeyen
Copy link

fayeyen commented Oct 20, 2017

@chaliaga your solution ng build --env=prod --output-hashing none work for me, thank you

@luis-jaramillo
Copy link

ng build --prod --aot=false

works for me!

@xiongyayun428
Copy link

@lfjaramillos
i use ng build --prod --aot=false

Uncaught Error: Unexpected value 'e' imported by the module 'e'. Please add a @NgModule annotation.
    at d (main.8a985f069dffc6432a08.bundle.js:1)
    at main.8a985f069dffc6432a08.bundle.js:1
    at Array.forEach (<anonymous>)
    at e.getNgModuleMetadata (main.8a985f069dffc6432a08.bundle.js:1)
    at e._loadModules (main.8a985f069dffc6432a08.bundle.js:1)
    at e._compileModuleAndComponents (main.8a985f069dffc6432a08.bundle.js:1)
    at e.compileModuleAsync (main.8a985f069dffc6432a08.bundle.js:1)
    at e.compileModuleAsync (main.8a985f069dffc6432a08.bundle.js:1)
    at e.bootstrapModule (main.8a985f069dffc6432a08.bundle.js:1)
    at Object.cDNt (main.8a985f069dffc6432a08.bundle.js:1)

@xiongyayun428
Copy link

@chaliaga
I use ng build --env=prod --output-hashing
angular/cli: 1.5.0
angular: 5.0.0

compiler.js:466 Uncaught Error: Unexpected value 'XyyModule' imported by the module 'CoreModule'. Please add a @NgModule annotation.
    at syntaxError (compiler.js:466)
    at compiler.js:15088
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.webpackJsonp.../../../compiler/esm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:15071)
    at CompileMetadataResolver.webpackJsonp.../../../compiler/esm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (compiler.js:14998)
    at compiler.js:15086
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.webpackJsonp.../../../compiler/esm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:15071)
    at JitCompiler.webpackJsonp.../../../compiler/esm5/compiler.js.JitCompiler._loadModules (compiler.js:33484)
    at JitCompiler.webpackJsonp.../../../compiler/esm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:33445)

@adyontech
Copy link

@chaliaga, thanks for the solution it really worked like magic.
is it possible to explain the reason behind working where other deploy rule got failed?

@ayyagarian
Copy link

I'm getting an error while running the production build with AOT compiler. Can anyone guide me with a solution here?

ERROR in : Unexpected value 'ChartistModule in I:/Front end/c3ctoken/frontend/node_modules/ng-chartist/bundles/ng-chartist.umd.js' imported by the module 'AppModule in I:/Front end/c3ctoken/frontend/src/app/app.module.ts'. Please add a @NgModule annotation

@hakimio
Copy link
Collaborator

hakimio commented Feb 5, 2019

@Dead-Cool Which version of ng-chartist, Angular and Angular CLI are you using?

@ayyagarian
Copy link

@Dead-Cool Which version of ng-chartist, Angular and Angular CLI are you using?

I'm using Angular 7, CLI 7 and Chartist 0.11 version.

@hakimio
Copy link
Collaborator

hakimio commented Feb 5, 2019

NG-chartist. Which version of this library are you using? Are you using the latest 4.1?

@hakimio
Copy link
Collaborator

hakimio commented Feb 5, 2019

Can you run ng --version to get exact version numbers?

@ayyagarian
Copy link

Can you run ng --version to get exact version numbers?

"@angular/animations": "github:angular/animations-builds",
"@angular/cdk": "^7.2.0",
"@angular/common": "~7.1.0",
"@angular/compiler": "~7.1.0",
"@angular/core": "~7.1.0",
"@angular/forms": "~7.1.0",
"@angular/http": "^7.1.4",
"@angular/material": "^7.2.0",
"@angular/platform-browser": "~7.1.0",
"@angular/platform-browser-dynamic": "~7.1.0",
"@angular/router": "~7.1.0",
"@types/jquery": "^3.3.29",
"angular-bootstrap-md": "^7.1.1",
"angular-material": "^1.1.11",
"angularfire2": "^5.1.1",
"bootstrap": "^4.2.1",
"chart.js": "^2.7.3",
"chartist": "^0.11.0",
"core-js": "^2.5.4",
"dexie": "^2.0.4",
"firebase": "^5.7.2",
"firebase-tools": "^6.2.2",
"hammerjs": "^2.0.8",
"indexeddb-angular": "^0.1.8",
"jquery": "^3.3.1",
"lodash": "^4.17.11",
"ng-chartist": "^2.0.0-beta.1",
"ng2-charts": "^1.6.0",
"ngx-bootstrap": "^3.2.0",
"ngx-pagination": "^3.2.1",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"

@hakimio
Copy link
Collaborator

hakimio commented Feb 5, 2019

You are using an old version of ng-chartist which had the bug. You have to update it.

@ayyagarian
Copy link

What is the commad to update it?

@hakimio
Copy link
Collaborator

hakimio commented Feb 5, 2019

You can use something like npm-check-updates to automatically update your package.json (ncu -u) or you can manually change "ng-chartist": "^2.0.0-beta.1" to "ng-chartist": "^4.1.0". Then just run npm install.

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

No branches or pull requests