chartjs-plugin-datalabels icon indicating copy to clipboard operation
chartjs-plugin-datalabels copied to clipboard

Error running the latest chartjs-plugin-datalabels with NextJS

Open DecadentIpsum opened this issue 2 years ago • 21 comments

Hello,

I am developing a NextJS site and I installed the latest "chartjs-plugin-datalabels".

When I am running my project I got the following error:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './helpers' is not defined by "exports" in /Users/zaralisandreas/Desktop/Projects/odify/node_modules/chart.js/package.json

I am using Node v18.12.1 and Chart.js 4.0.1.

Any ideas?

I really appreciate any help you can provide.

DecadentIpsum avatar Nov 21 '22 18:11 DecadentIpsum

Same issues here.

dqve avatar Nov 22 '22 02:11 dqve

@simonbrunel any ideas? :)

DecadentIpsum avatar Nov 27 '22 20:11 DecadentIpsum

This package uses chart.js 3.0

Igosuki avatar Nov 29 '22 11:11 Igosuki

@DecadentIpsum Sorry, no idea. Do you use any other Chart.js plugins that actually work with your setup?

You could try with the new plugin version 2.2.0, however I don't think it will change anything.

If you need people to help you with your issue, you will have to provide a way to reproduce it.

simonbrunel avatar Dec 10 '22 11:12 simonbrunel

Same problem here. I deleted node_modules, yarn.lock and even cleared cache before installing dependencies again but nothing worked.

ignaciodiazb avatar Dec 11 '22 00:12 ignaciodiazb

@simonbrunel I think the plugin must be defined as "module" and defines the exports. See https://github.com/chartjs/chartjs-plugin-annotation/pull/815 and other plugins (gradient https://github.com/kurkle/chartjs-plugin-gradient/blob/master/package.json)

stockiNail avatar Dec 12 '22 07:12 stockiNail

Same here, no other plugins. Just the latest version of both packages. Screenshot 2022-12-12 at 1 13 41 PM

NotTimTam avatar Dec 12 '22 20:12 NotTimTam

Thanks @stockiNail for the info. While you are probably right, I don't want to blindly push these changes but first would like to experiment with the reported cases. Also, we need to be sure that it doesn't break existing integrations since changing type: "module" may have broader implications.

@DecadentIpsum @dqve @ignaciodiazb @NotTimTam can one of you please share a minimal repo that reproduces this issue? I'm not familiar with Next.js and don't have much time to figure out by myself.

simonbrunel avatar Dec 13 '22 07:12 simonbrunel

@simonbrunel thanks a lot for your interest in resolving this issue 🙂

Here is a minimal repo with the reproduction of the issue https://codesandbox.io/s/elated-haze-d3fj4w?file=/pages/index.js

DecadentIpsum avatar Dec 13 '22 08:12 DecadentIpsum

Same issue here. I am using sveltekit version 1.0 and Vite 4.0

The big change with Vite4 was the switch to Rollup3.

That's interesting because the dev server built into vite uses ESBuild. The dev server using ESBuild runs the project just fine.

I only run into issues when I try to use Rollup3 to build the project.

Fish1 avatar Dec 15 '22 04:12 Fish1

hanks @stockiNail for the info. While you are probably right, I don't want to blindly push these changes but first would like to experiment with the reported cases. Also, we need to be sure that it doesn't break existing integrations since changing type: "module" may have broader implications.

@simonbrunel Maybe it can help: https://github.com/chartjs/Chart.js/pull/10914#issuecomment-1326685660 CommonJS is not supported anymore from CHART.JS 4.

stockiNail avatar Dec 15 '22 11:12 stockiNail

Thanks @stockiNail! I'm very surprised about such decision. I'm also wondering if it's actually the root cause of plugins breaking in NextJS or if it's unrelated.

simonbrunel avatar Dec 15 '22 12:12 simonbrunel

Thanks @stockiNail! I'm very surprised about such decision. I'm also wondering if it's actually the root cause of plugins breaking in NextJS or if it's unrelated.

It shouldn't be related (but my knowledge is so low about JS packaging, therefore don't trust my answer!).

stockiNail avatar Dec 15 '22 12:12 stockiNail

Also getting this with "next": "13.0.3", "chart.js": "4.0.1", and "chartjs-plugin-datalabels": "2.2.0".

Hopefully a fix is coming in soon.

epleaner avatar Dec 15 '22 20:12 epleaner

Same here, having problems with chart.js v4 and the latest version of "chartjs-plugin-datalabels"

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './helpers' is not defined by...

Hoping for a soon fix, thanks.

dahsser avatar Dec 17 '22 06:12 dahsser

Noticed that chartjs 4.1.1 was released yesterday.

Bumped up the version to 4.1.1 in the previously shared codesandbox, and all appears to be working!

https://codesandbox.io/s/objective-panka-ewx6tu

Fish1 avatar Dec 18 '22 12:12 Fish1

I can confirm that ChartJS 4.1.1 seems to clear the error!

DecadentIpsum avatar Dec 19 '22 06:12 DecadentIpsum

That's a good news! Thanks @Fish1 and @DecadentIpsum for checking and keep us updated.

@dqve @ignaciodiazb @NotTimTam @epleaner @dahsser can you guys also confirm that Chart 4.1.1 fixes your issue?

simonbrunel avatar Dec 19 '22 07:12 simonbrunel

Yes. chart.js 4.1.1 solves the problem

ignaciodiazb avatar Dec 19 '22 13:12 ignaciodiazb

I had the same problem using nextJs. Chart.js 4.1.1 and chartjs-plugin-datalabels 2.2.0 worked perfectly

anthgrim avatar Dec 27 '22 15:12 anthgrim

the problem with your chart.js version just upgrade chart.js version to 4.2.1, this is work Screen Shot 2023-04-06 at 12 24 59

Screen Shot 2023-04-06 at 12 25 37

imronpuji avatar Apr 06 '23 05:04 imronpuji