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 Error: Uncaught (in promise): TypeError: Object(...) is not a function #1117

Closed
mshubhamtyagi opened this issue Jun 5, 2019 · 20 comments

Comments

@mshubhamtyagi
Copy link

Reproduction of the problem

ng2-charts is a port & modification of Chart.js component for Angular 2. Sometimes the issue is related to Chart.js instead of ng2-charts.
To confirm, if the issue shows in a pure Chart.js project, it is an issue of Chart.js.
Pure Chart.js starting template: https://jsfiddle.net/Hongbo_Miao/mvct2uwo/3/

If the issue does not show in a pure Chart.js project and shows in an
Screenshot from 2019-06-05 13-27-55
the ng2-charts project, please try to provide a minimal demo of the problem.
ng2-charts starting template: http://plnkr.co/edit/Ka4NXG3pZ1mXnaN95HX5?p=preview

@fermedina
Copy link

The same issue

@mix5003
Copy link

mix5003 commented Jun 5, 2019

i think it like #1115.
try npm install ng2-charts@~2.2.5, and run agian

@ellieraya
Copy link

Hi,

I have ng chart in production and I am facing the same issue. Can somebody suggest for solutions asap.
_

@tranvannhat
Copy link

with me, i edit code in ./node_modules/ng2-charts/fesm5/ng2-charts.js find and replace ɵɵdefineInjectable to defineInjectable. It's working with me, but i don't want edit lib, can you update lib?

@DeepaliMadge
Copy link

same error.

@raksha-rathore
Copy link

i am also facing this error. anyone got the solution?

@RbkGh
Copy link

RbkGh commented Jun 11, 2019

same issue here too.any appropriate fix aside editing ɵɵdefineInjectable in library?

@raksha-rathore
Copy link

i used the older release 2.2.0 and the issue is not coming there. earlier i was using 2.2.4 version. I have not tried 2.2.5.
For now my code is working with 2.2.0 version

@RbkGh
Copy link

RbkGh commented Jun 11, 2019

I just realized any version <=2.2.3 works.
So just open package.json and update ng2-charts version accordingly.

@nla-asia
Copy link

2.2.5 works for me.

@abalad
Copy link

abalad commented Jun 12, 2019

npm install ng2-charts@~2.2.5 --save works for me

@amitvermaknw
Copy link

amitvermaknw commented Jun 26, 2019

I agree with @tranvannhat , I also edit the code in ./node_modules/ng2-charts/fesm5/ng2-charts.js and replace ɵɵdefineInjectable to defineInjectable and it's working fine. ng2-chart team can you update this? As we are using this lib in prod and while building on prod I cannot push my local lib. it will fetch from repo.

For me issue is with Angular 7.

@bryplano
Copy link

bryplano commented Jun 26, 2019

As a few folks have noted, I was able to update to v2.2.5 and this issue was fixed in an Angular 7 project:

npm install [email protected] --save

The error popped up after there was a change to build this project (ng2-charts) with Angular 8. That change was reverted with Release v2.2.5: https://github.com/valor-software/ng2-charts/releases/tag/2.2.5

v2.3.0 has been upgraded to use Angular 8 or Angular 7 (so it should - in theory - also work): ec5e603#diff-e86dda6566477895fbf685c476288762

Angular's official repo has an issue on this type of error if you're interested: angular/angular#30413

@rcrodrigues
Copy link

rcrodrigues commented Jun 27, 2019

@bryplano I've just updated ng2-charts to v2.3.0 on an Angular 8 project and this error popped up as well.

@bryplano
Copy link

@rcrodrigues thanks for checking! Shame the change broke this (and other) libs, but it sounds like it's intended per this post: angular/angular#30413 (comment)

Given all the above, I don't see how this issue is actionable, so I'll go ahead and close this. My advise would be to keep building your library using the minimally required Angular version.

Guess sticking at 2.2.5 is currently advisable @rcrodrigues :\

@jorroll
Copy link

jorroll commented Jun 30, 2019

For those interested, upgrading my app to Angular v8 and using ng2-charts v2.3.0 fixes this issue for me.

As indicated in the helpfully linked angular/angular#30413, this issue was caused by compiling this library using the Angular v8 compiler. Libraries which support either Angular v7 || v8 must be compiled using angular v7.

cc: @bryplano - pinging you because it sounds like you might be interested to know that ng2-charts v2.3.0 can (does?) work with the latest version of Angular v8 (v8.0.3 as of writing).

@s-ramesh
Copy link

s-ramesh commented Sep 30, 2020

I am also facing the same issue I upgrade to 2.2.5 ng serve works fine but ng build it is showing the same error "Uncaught TypeError: Object(...) is not a function" any one help asap.

@paviad
Copy link
Contributor

paviad commented Sep 30, 2020

Curious - why are you using an older version? Current version is 2.4.2

@paviad
Copy link
Contributor

paviad commented Sep 30, 2020

I just created a fresh angular app using @angular/cli@^8.0.0 and imported ChartsModule from [email protected] - no problems. It's not the angular version, or the library... something else in your setup is the issue.

Stackblitz example https://stackblitz.com/edit/ng2-charts-angular-8

@gooligari
Copy link

i am getting ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function while implementing ng2-charts. I tried with Below versions but nothing is helping. Thanks in advance.
ng2-charts : 2.2.0 & 2.2.5 & 2.2.4 & 2.4.2
Angular : 5
"chart.js": "^2.9.3",

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