-
-
Notifications
You must be signed in to change notification settings - Fork 380
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
Attempted import error: 'canvas-confetti' does not contain a default export (imported as 'confetti'). in nextjs #222
Comments
Hmm... I know other people are successfully using this module in their nextjs project. Are you fully describing the problem you are having? |
I was having the same issue when using this in my rails app. I managed to fix it by doing for example: import "canvas-confetti"; //--------- ** --------- confetti({ Hopefully that helps. |
Just to make sure there isn't anything I don't understand, I just created a new app using "use client";
import confetti from "canvas-confetti";
export const ConfettiButton = () => {
return <button onClick={() => {
confetti();
}}>click for confetti</button>
}; Then I used this button without an issue, never receiving an error. I don't doubt that y'all are having an issue, but the repro steps seem non-obvious. Please describe how I can reproduce the issue. Providing a minimal repro app is usually the best way to make sure an issue gets looked at. |
When using Typescript then make sure 'allowUmdGlobalAccess' is enabled in tsconfig. |
you can export the default confetti form canvas-confetti. |
I'm using NextJS v14.1.0 and Typescript. I solve it by doing |
try to build then you must see |
@Md-Anamul-Haque, try using the react version - https://github.com/ulitcos/react-canvas-confetti |
@Md-Anamul-Haque I don't understand what you mean by "try to build then you must see". I did build it. It worked fine. Builds without error, the web page shows a button and clicking that button launches confetti. Do you have an application that you have built that you can show here to help with debugging? |
you use now typescript + nodejs |
I'm running into this issue after upgrading my app from Next.js 14.0.4 to 14.1+. I've been able to reproduce this with Next.js 14.1.1 and 14.2.3. If I create a new sample Next.js app using Next.js version 14.2.3 (the latest), my confetti component with the exact same code as my real app is able to render in this sample app. I also tried moving my confetti component to be a child of my real application's root, (trying to isolate it from something strange that could be happening upstream in the tree) but that also doesn't work. I'm pretty stumped as to why I'm able to use this component at the root of my demo app but not my real app.
|
I think something with Typescript ? are you picking typescript when setting up with |
yes |
Attempted import error: 'canvas-confetti' does not contain a default export (imported as 'confetti'). in nextjs
The text was updated successfully, but these errors were encountered: