valor-software / ng2-charts

Beautiful charts for Angular based on Chart.js
http://valor-software.github.io/ng2-charts/
MIT License
2.34k stars 572 forks source link

Angular 16 error due to ng2-charts-schematics #1681

Closed sydneyhenrard closed 11 months ago

sydneyhenrard commented 1 year ago

I migrated from Angular 15.2.0 to Angular 16.1.6 and tried to upgrade from ng2-charts 4.1.1 to 5.0.1. I got this error due to ng2-charts-schematics when running npm install.

npm WARN Could not resolve dependency:
npm WARN peer ng2-charts-schematics@"0.0.1" from ng2-charts@5.0.1
npm WARN node_modules/ng2-charts
npm WARN   ng2-charts@"^5.0.1" from the root project

package.json

"dependencies": {
    "@angular/animations": "^16.1.6",
    "@angular/cdk": "^16.1.5",
    "@angular/common": "^16.1.6",
    "@angular/compiler": "^16.1.6",
    "@angular/core": "^16.1.6",
    "@angular/forms": "^16.1.6",
    "@angular/material": "^16.1.5",
    "@angular/platform-browser": "^16.1.6",
    "@angular/platform-browser-dynamic": "^16.1.6",
    "@angular/router": "^16.1.6",
    "angular-oauth2-oidc": "^15.0.1",
    "chart.js": "^4.3.0",
    "chartjs-adapter-date-fns": "^3.0.0",
    "cross-env": "^7.0.3",
    "date-fns": "^2.30.0",
    "flag-icons": "^6.7.0",
    "ng2-charts": "^5.0.1",
    "ngx-auto-unsubscribe": "^3.0.1",
    "ngx-date-fns": "^10.0.1",
    "ngx-google-analytics": "^14.0.1",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.13.1"
  },
anishchenko-anton commented 1 year ago

I have the same issue

uplink42 commented 1 year ago

Same error here. I'm unable to install any of the v5 versions:

$ npm i --save ng2-charts npm WARN ERESOLVE overriding peer dependency npm WARN While resolving: ng2-charts@5.0.1 npm WARN Found: ng2-charts-schematics@undefined npm WARN node_modules/ng2-charts-schematics npm WARN npm WARN Could not resolve dependency: npm WARN peer ng2-charts-schematics@"0.0.1" from ng2-charts@5.0.1 npm WARN node_modules/ng2-charts npm WARN ng2-charts@"*" from the root project

MikaStark commented 1 year ago

Same issue.

I tried to install it on a blank project and the schematic install version 4 instead of 5. But it worked. It worth nothing to say that the schematic is not compatible with standalone project.

wjehring commented 1 year ago

I'm not sure about the build/npm publish process that's used for this project, but the issue is that the schematic package.json references a version that doesn't exist on npm.

When the ng2-charts lib is built, nx automatically generates the dependencies in the package.json using that version number, but it doesn't exist on npm. I imagine updating the schematics version to one that does exist in npm would fix this.

In the meantime, you should be able to fix this in your own project by adding this to your package.json:

"overrides": {
  "ng2-charts": {
    "ng2-charts-schematics": "0.1.7"
  }
}
changhuixu commented 1 year ago

having same issue here. seems like the ng2-charts-schematics is required.

Also, when using ng add ng2-charts, it installs chart.js v3.6.0 instead of v4

maranmaran commented 12 months ago

Thumbs up

ekselys commented 12 months ago

same here

Muminniyoz commented 12 months ago

same problem

FerAnimaciones commented 12 months ago

same problem 🙂

SebastianStehle commented 11 months ago

Same here. Do you need support or funding to handle this asap. It is a show blocker for me :(

tobigit commented 11 months ago

Same Problem here.

SebastianStehle commented 11 months ago

Sorry, I have not seen @wjehring solution ;)

ptomaszi commented 11 months ago

Same problem

idenisovs commented 11 months ago

I'm not sure, if it is the same, but today, during the ng add ng2-charts I got the follwing:

Collection "/private/tmp/testable/node_modules/ng2-charts/schematics/src/collection.json" cannot be resolved.

It is complete new project, just created with ng new command, the Angular version 16.2.0.

dhakerbadri commented 11 months ago

Thank you @wjehring !

wjehring commented 11 months ago

Sounds like people are getting round this issue with the package.json overrides.

If you see any complaints during dependency installation due to @angular/platform-browser then you may also need to add this override.

santam85 commented 11 months ago

This should be fixed in 5.0.3