ng2-charts: Angular 16 error due to ng2-charts-schematics

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"
  },

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 18
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

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"
  }
}

This should be fixed in 5.0.3

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

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.

Thank you @wjehring !

Sorry, I have not seen @wjehring solution 😉

same problem 🙂