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 running the latest chartjs-plugin-datalabels with NextJS #350

Open
DecadentIpsum opened this issue Nov 21, 2022 · 21 comments
Open

Error running the latest chartjs-plugin-datalabels with NextJS #350

DecadentIpsum opened this issue Nov 21, 2022 · 21 comments

Comments

@DecadentIpsum
Copy link

DecadentIpsum commented Nov 21, 2022

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.

@dqve
Copy link

dqve commented Nov 22, 2022

Same issues here.

@DecadentIpsum
Copy link
Author

@simonbrunel any ideas? :)

@Igosuki
Copy link

Igosuki commented Nov 29, 2022

This package uses chart.js 3.0

@simonbrunel
Copy link
Member

@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.

@ignaciodiazb
Copy link

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

@stockiNail
Copy link
Contributor

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

@NotTimTam
Copy link

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

@simonbrunel
Copy link
Member

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.

@DecadentIpsum
Copy link
Author

@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

@Fish1
Copy link

Fish1 commented Dec 15, 2022

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.

@stockiNail
Copy link
Contributor

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: chartjs/Chart.js#10914 (comment)
CommonJS is not supported anymore from CHART.JS 4.

@simonbrunel
Copy link
Member

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.

@stockiNail
Copy link
Contributor

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!).

@epleaner
Copy link

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.

@dahsser
Copy link

dahsser commented Dec 17, 2022

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.

@Fish1
Copy link

Fish1 commented Dec 18, 2022

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

@DecadentIpsum
Copy link
Author

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

@simonbrunel
Copy link
Member

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?

@ignaciodiazb
Copy link

Yes. chart.js 4.1.1 solves the problem

@anthgrim
Copy link

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

@imronpuji
Copy link

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

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