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

Make NPM peer dependency with chartjs ^4.0.0 valid #428

Open
SteamWind opened this issue Jan 9, 2025 · 3 comments
Open

Make NPM peer dependency with chartjs ^4.0.0 valid #428

SteamWind opened this issue Jan 9, 2025 · 3 comments

Comments

@SteamWind
Copy link

I have chartjs v4 installed but npm warn me about missing peer dependency because of this plugin:
npm WARN chartjs-plugin-datalabels@2.0.0 requires a peer of chart.js@^3.0.0 but none is installed. You must install peer dependencies yourself.
Chartjs awesome clearly state that it is compatible with chartjs 4 and the plugin works with this version.
There should be something wrong with the package configuration of this plugin.
Is it easily fixable?

@Whobeu
Copy link

Whobeu commented Jan 9, 2025

I have not had any problems but I am using a slightly newer version. The relevant lines from my package.json are:

    "canvas": "^2.11.2",
    "chart.js": "^4.4.1",
    "chartjs-plugin-datalabels": "^2.2.0",

@SteamWind
Copy link
Author

Ok I understood the problem.
You have to fix the version of the plugin to the newer version. Although you are using the "^" wildcard.
The package.json version which is defined (^2.0.0 ) is interpreted as 2.0.0 and not the latest minor release. So the peer dependency is not met. I had to fix the version to the newer one ("^2.2.0").

I just didn't understood why the package.lock was not used to check peer dependencies.

@Whobeu
Copy link

Whobeu commented Jan 9, 2025

After posting I noticed my package-lock.json has Chart.js at version 4.4.3 so the minor update of that went through the last time I ran an update.

From time to time I run the "ncu" (npm-check-updates) utility to check for any needed updates to package.json. Sometimes though it causes breaking changes when there is a major package update so I use it with care. I just ran it in advisory mode and it tells me there is a Chart.js 4.4.7 update as well as Canvas 3.0.1. I am inclined to update Chart.js immediately but Canvas is going to need a review before I attempt it. Then again everything is working fine so I might just leave it all alone LOL.

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

2 participants