Ngx-charts: index.d.ts, found version 4, expected 3.. and Cannot read property 'length' of undefined at LineChartComponen

Created on 16 Nov 2017  Â·  8Comments  Â·  Source: swimlane/ngx-charts

trying to implementing <ngx-charts-line-chart>
but getting this error:

ERROR in Metadata version mismatch for module C:/Users/Pawel/desktop/code/pami/node_modules/@swimlane/ngx-charts/release
/index.d.ts, found version 4, expected 3, resolving symbol AppModule in C:/Users/Pawel/desktop/code/pami/src/app/app.mod
ule.ts, resolving symbol AppModule in C:/Users/Pawel/desktop/code/pami/src/app/app.module.ts

as well ass:

TypeError: Cannot read property 'length' of undefined
at LineChartComponent../src/line-chart/line-chart.component.ts.LineChartComponent.getXDomain...

package.json:

> `{
>   "name": "pami",
>   "version": "0.0.0",
>   "license": "MIT",
>   "scripts": {
>     "ng": "ng",
>     "start": "ng serve",
>     "build": "ng build",
>     "test": "ng test",
>     "lint": "ng lint",
>     "e2e": "ng e2e"
>   },
>   "private": true,
>   "dependencies": {
>     "@angular/animations": "^5.0.2",
>     "@angular/common": "^4.0.0",
>     "@angular/compiler": "^4.0.0",
>     "@angular/core": "^4.0.0",
>     "@angular/forms": "^4.0.0",
>     "@angular/http": "^4.0.0",
>     "@angular/platform-browser": "^4.0.0",
>     "@angular/platform-browser-dynamic": "^4.0.0",
>     "@angular/router": "^4.0.0",
>     "@firebase/webchannel-wrapper": "0.2.3",
>     "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
>     "@swimlane/ngx-charts": "^7.0.0",
>     "angularfire2": "^5.0.0-rc.2",
>     "bootstrap": "^4.0.0-alpha.6",
>     "bootswatch": "^4.0.0-beta.2",
>     "core-js": "^2.4.1",
>     "d3": "^4.11.0",
>     "firebase": "^4.5.0",
>     "font-awesome": "^4.7.0",
>     "ng-sidebar": "^6.0.2",
>     "promise-polyfill": "6.0.2",
>     "rxjs": "^5.1.0",
>     "zone.js": "^0.8.4"
>   },
>   "devDependencies": {
>     "@angular/cli": "1.0.1",
>     "@angular/compiler-cli": "^4.0.0",
>     "@types/jasmine": "2.5.38",
>     "@types/node": "~6.0.60",
>     "codelyzer": "~2.0.0",
>     "jasmine-core": "~2.5.2",
>     "jasmine-spec-reporter": "~3.2.0",
>     "karma": "~1.4.1",
>     "karma-chrome-launcher": "~2.0.0",
>     "karma-cli": "~1.0.1",
>     "karma-jasmine": "~1.1.0",
>     "karma-jasmine-html-reporter": "^0.2.2",
>     "karma-coverage-istanbul-reporter": "^0.2.0",
>     "protractor": "~5.1.0",
>     "ts-node": "~2.0.0",
>     "tslint": "~4.5.0",
>     "typescript": "~2.2.0"
>   }
> }
> `

Most helpful comment

My error was:

ERROR in Error: Metadata version mismatch for module C:/temp/chartsTest/something/node_modules/@swimlane/ngx-charts/release/index.d.ts, found version 4, expected 3,
resolving symbol AppModule in C:/temp/chartsTest/something/src/app/app.module.ts,
resolving symbol AppModule in C:/temp/chartsTest/something/src/app/app.module.ts

at syntaxError (C:\temp\chartsTest\something\node_modules\@angular\compiler\bundles\compiler.umd.js:1729:34)
at simplifyInContext (C:\temp\chartsTest\something\node_modules\@angular\compiler\bundles\compiler.umd.js:24979:23)
at StaticReflector.simplify (C:\temp\chartsTest\something\node_modules\@angular\compiler\bundles\compiler.umd.js:24991:13)
at StaticReflector.annotations (C:\temp\chartsTest\something\node_modules\@angular\compiler\bundles\compiler.umd.js:24418:41)
at _getNgModuleMetadata (C:\temp\chartsTest\something\node_modules\@angular\compiler-cli\src\ngtools_impl.js:138:31)
at _extractLazyRoutesFromStaticModule (C:\temp\chartsTest\something\node_modules\@angular\compiler-cli\src\ngtools_impl.js:109:26)
at Object.listLazyRoutesOfModule (C:\temp\chartsTest\something\node_modules\@angular\compiler-cli\src\ngtools_impl.js:53:22)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\temp\chartsTest\something\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39)
at AotPlugin._getLazyRoutesFromNgtools (C:\temp\chartsTest\something\node_modules\@ngtools\webpack\src\plugin.js:212:44)
at _donePromise.Promise.resolve.then.then.then.then.then (C:\temp\chartsTest\something\node_modules\@ngtools\webpack\src\plugin.js:448:24)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

All 8 comments

Going back to 6.1.0 fixed this for me.

My error was:

ERROR in Error: Metadata version mismatch for module C:/temp/chartsTest/something/node_modules/@swimlane/ngx-charts/release/index.d.ts, found version 4, expected 3,
resolving symbol AppModule in C:/temp/chartsTest/something/src/app/app.module.ts,
resolving symbol AppModule in C:/temp/chartsTest/something/src/app/app.module.ts

at syntaxError (C:\temp\chartsTest\something\node_modules\@angular\compiler\bundles\compiler.umd.js:1729:34)
at simplifyInContext (C:\temp\chartsTest\something\node_modules\@angular\compiler\bundles\compiler.umd.js:24979:23)
at StaticReflector.simplify (C:\temp\chartsTest\something\node_modules\@angular\compiler\bundles\compiler.umd.js:24991:13)
at StaticReflector.annotations (C:\temp\chartsTest\something\node_modules\@angular\compiler\bundles\compiler.umd.js:24418:41)
at _getNgModuleMetadata (C:\temp\chartsTest\something\node_modules\@angular\compiler-cli\src\ngtools_impl.js:138:31)
at _extractLazyRoutesFromStaticModule (C:\temp\chartsTest\something\node_modules\@angular\compiler-cli\src\ngtools_impl.js:109:26)
at Object.listLazyRoutesOfModule (C:\temp\chartsTest\something\node_modules\@angular\compiler-cli\src\ngtools_impl.js:53:22)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\temp\chartsTest\something\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39)
at AotPlugin._getLazyRoutesFromNgtools (C:\temp\chartsTest\something\node_modules\@ngtools\webpack\src\plugin.js:212:44)
at _donePromise.Promise.resolve.then.then.then.then.then (C:\temp\chartsTest\something\node_modules\@ngtools\webpack\src\plugin.js:448:24)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

@neo-xy @Jacquers ngx-charts v7.0.0 supports Angular 5 only. The error you got was because you are using "@angular/compiler": "^4.0.0" which complains about a version mismatch in the metadata when using the Angular 5 compiled ngx-charts version 7.0.0.

You should use v7.0.0 after upgrading to Angular 5.

@neo-xy I'm using Angular 4.0.2, and I needed to use ngx-charts in it's 6.0.2 version to avoid this mismatch error. 6.1.0 seems to be for Angular 4.3 and higher and 7.0.0 seems to be for Angular 5.0

The undefined errormight be code related issue on your side sending the wrong data to the chart.
For this chart, the library expect a multi data sample and not a simple one as you can see here :
https://swimlane.gitbooks.io/ngx-charts/content/charts/line-chart.html

@GaetanWi thank you alot guys, -how the hell I missed that I had 'simple' instead of 'multi' I don't even know:/ -take care(y)

@GaetanWi solved it for me, i just changed my
"@swimlane/ngx-charts": "^7.0.0",
to
"@swimlane/ngx-charts": "6.0.2",
in my json.

using angular 4.2, thnk you so much!

have the same error:
ERROR in Error: Metadata version mismatch for module C:/Users/Вова/home-money/node_modules/@swimlane/ngx-charts/release/index.d.ts, found version 4, expected 3, resolving symbol Shar edModule in C:/Users/Вова/home-money/src/app/shared/shared.module.ts, resolving symbol SharedModule in C:/Users/Вова/home-money/src/app/shared/shared.module.ts [0] at syntaxError (C:\Users\Вова\home-money\node_modules\@angular\compiler\bundles\compiler.umd.js:1729:34) [0] at simplifyInContext (C:\Users\Вова\home-money\node_modules\@angular\compiler\bundles\compiler.umd.js:24979:23) [0] at StaticReflector.simplify (C:\Users\Вова\home-money\node_modules\@angular\compiler\bundles\compiler.umd.js:24991:13) [0] at StaticReflector.annotations (C:\Users\Вова\home-money\node_modules\@angular\compiler\bundles\compiler.umd.js:24418:41) [0] at _getNgModuleMetadata (C:\Users\Вова\home-money\node_modules\@angular\compiler-cli\src\ngtools_impl.js:138:31) [0] at _extractLazyRoutesFromStaticModule (C:\Users\Вова\home-money\node_modules\@angular\compiler-cli\src\ngtools_impl.js:109:26) [0] at C:\Users\Вова\home-money\node_modules\@angular\compiler-cli\src\ngtools_impl.js:129:27 [0] at Array.reduce (<anonymous>) [0] at _extractLazyRoutesFromStaticModule (C:\Users\Вова\home-money\node_modules\@angular\compiler-cli\src\ngtools_impl.js:128:10) [0] at C:\Users\Вова\home-money\node_modules\@angular\compiler-cli\src\ngtools_impl.js:129:27 [0] at Array.reduce (<anonymous>) [0] at _extractLazyRoutesFromStaticModule (C:\Users\Вова\home-money\node_modules\@angular\compiler-cli\src\ngtools_impl.js:128:10) [0] at Object.listLazyRoutesOfModule (C:\Users\Вова\home-money\node_modules\@angular\compiler-cli\src\ngtools_impl.js:53:22) [0] at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\Users\Вова\home-money\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39) [0] at AotPlugin._getLazyRoutesFromNgtools (C:\Users\Вова\home-money\node_modules\@ngtools\webpack\src\plugin.js:240:66) [0] at _donePromise.Promise.resolve.then.then.then.then.then (C:\Users\Вова\home-money\node_modules\@ngtools\webpack\src\plugin.js:493:24)
my package.json:
{ "name": "home-money", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "server": "json-server --watch db.json --port 3000", "dev": "concurrently --kill-others \"npm run start\" \"npm run server\"" }, "private": true, "dependencies": { "@angular/animations": "^4.4.6", "@angular/common": "^4.2.4", "@angular/compiler": "^4.2.4", "@angular/core": "^4.2.4", "@angular/forms": "^4.2.4", "@angular/http": "^4.2.4", "@angular/platform-browser": "^4.2.4", "@angular/platform-browser-dynamic": "^4.2.4", "@angular/router": "^4.2.4", "@swimlane/ngx-charts": "^7.1.1", "core-js": "^2.4.1", "d3": "^5.0.0", "moment": "^2.21.0", "rxjs": "^5.4.2", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "^1.7.3", "@angular/compiler-cli": "^4.2.4", "@angular/language-service": "^4.2.4", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "~3.1.1", "concurrently": "^3.5.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.3.2", "typescript": "~2.3.3" } }
and app.module.ts:
`import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { AppComponent } from './app.component';
import { AuthModule } from './auth/auth.module';
import { AppRoutingModule } from './app-routing.module';
import { UsersService } from './shared/services/users.service';
import { AuthService } from './shared/services/auth.service';
import { SystemModule } from './system/system.module';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpModule,
AuthModule,
AppRoutingModule,
SystemModule,
BrowserAnimationsModule
],
providers: [UsersService, AuthService],
bootstrap: [AppComponent]
})
export class AppModule { }
`
i changed my
"@swimlane/ngx-charts": "^7.0.0",
to
"@swimlane/ngx-charts": "6.0.2",
but it did not help.

So what to do that it works?

ERROR in Error: Metadata version mismatch for module C:/Users/Mrk01/Desktop/ordofy1/node_modules/@angular/material/core/typings/index.d.ts, found version 4, expected 3, resolving symbol AppModule in C:/Users/Mrk01/Desktop/ordofy1/src/app/app.module.ts, resolving symbol AppModule in C:/Users/Mrk01/Desktop/ordofy1/src/app/app.module.ts
at syntaxError (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@angular\compiler\bundles\compiler.umd.js:1729:34)
at simplifyInContext (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@angular\compiler\bundles\compiler.umd.js:24979:23)
at StaticReflector.simplify (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@angular\compiler\bundles\compiler.umd.js:24991:13)
at StaticReflector.annotations (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@angular\compiler\bundles\compiler.umd.js:24418:41)
at _getNgModuleMetadata (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@angular\compiler-cli\src\ngtools_impl.js:138:31)
at _extractLazyRoutesFromStaticModule (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@angular\compiler-cli\src\ngtools_impl.js:109:26)
at Object.listLazyRoutesOfModule (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@angular\compiler-cli\src\ngtools_impl.js:53:22)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39)
at AotPlugin._getLazyRoutesFromNgtools (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@ngtoolswebpack\src\plugin.js:240:66)
at _donePromise.Promise.resolve.then.then.then.then.then (C:\Users\Mrk01\Desktop\ordofy1\node_modules\@ngtoolswebpack\src\plugin.js:493:24)
at process._tickCallback (internal/process/next_tick.js:68:7)

i got this error while implememnting ngx image...while image compresing

Was this page helpful?
0 / 5 - 0 ratings