-
Notifications
You must be signed in to change notification settings - Fork 94
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
import error: 'swr' does not contain a default export (imported as 'swr'). #143
Comments
I got a workaround and understood the root cause of the issue. The root cause is the The possible exports: Tweet is because Tweet is exported from the local swr.js. As a work around I added a webpack config to my next.config.js
|
Keeping open so the root cause can be fixed. |
Use this way to import import { UserButton } from "@clerk/nextjs"; |
I am still facing this issue after importing import { UserButton } from "@clerk/next"; I am using these versions listed below.
Did anyone have a luck so far on this ? |
We are encountering a error related to the swr library with the react-tweet module in a Next.js application. The error manifests as a TypeError, specifically when trying to access the default export of the swr module within react-tweet. This issue is presenting challenges in both server-side and client-side contexts, affecting the normal operation of our Next.js application.
Error Details
The error we're encountering is as follows:
server side:
client:
The line of code causing the issue in react-tweet/dist/hooks.js is:
const useSWR = swr.default || swr;
This line suggests an attempt to handle both default and named exports of swr, but it fails because swr is undefined at this point.
Steps Taken to Resolve
Verified Import Syntax: Checked that swr is being imported correctly in react-tweet. The issue seems not to be with the import syntax but rather with the swr module resolution.
Checked Module Resolution: Explored potential module resolution issues, ensuring that swr is correctly installed and that there are no path discrepancies or version conflicts.
Reviewed Next.js Transpilation and Bundling: Investigated whether the Next.js build and transpilation process might be affecting how swr is bundled or executed, particularly in the context of server-side rendering (SSR).
Node Modules Reinstallation: Attempted deleting and reinstalling node_modules to rule out any corrupt or improperly installed packages.
Checked for Version Compatibility: Ensured that the versions of swr, react-tweet, and Next.js in use are compatible with each other.
Request for Assistance
Any guidance, especially from those who might have faced similar challenges, would be greatly appreciated. We are particularly interested in understanding why the swr module is resolving as undefined in this context and how we might address this in a Next.js environment.
The text was updated successfully, but these errors were encountered: