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

Can't import the named export 'createContext' from non EcmaScript module (only default export is available) #3058

Open
AmelloAster opened this issue Dec 24, 2024 · 16 comments

Comments

@AmelloAster
Copy link

Bug report

Description / Observed Behavior

In the project I created via create-react-app, when I run the build script, I get the following error

Failed to compile.

./node_modules/swr/dist/_internal/config-context-client-x_C9_NWC.mjs
Can't import the named export 'createContext' from non EcmaScript module (only default export is available)

What kind of issues did you encounter with SWR?
build error

Expected Behavior

build success
How did you expect SWR to behave here?

Repro Steps / Code Example

Or share your code snippet or a CodeSandbox link is also appreciated!

Additional Context

SWR version.
swr@2.3.0
Add any other context about the problem here.

@chenshuai2144
Copy link

chenshuai2144 commented Dec 24, 2024

+1 same error

1 similar comment
@yangzy0603
Copy link

+1 same error

@xuehao1997
Copy link

+1

@oliver34
Copy link

same error

@LaiDiang1025
Copy link

build same error 2.0.3

@HuangCQ-code
Copy link

Return to version 2.2.5

@rlscode
Copy link

rlscode commented Jan 17, 2025

same error, version 2.3.0

@yasmin-movingpay
Copy link

same error on version 2.3.0

@weizheweng
Copy link

same error on version 2.2.5 and 2.3.0

@huozhi
Copy link
Member

huozhi commented Feb 5, 2025

Can someone provide a reproduction so we can investigate, otherwise we're not able to procceed on this issue as the provide information is very limited

@ldwonday
Copy link

ldwonday commented Feb 24, 2025

+1

ERROR in ./node_modules/swr/dist/_internal/config-context-client-Cm1JTDEP.mjs 520:25-38
Can't import the named export 'createContext' from non EcmaScript module (only default export is available)
 @ ./node_modules/swr/dist/_internal/index.mjs
 @ ./node_modules/swr/dist/index/index.mjs

@yeonkyungnae
Copy link

same error on version 2.2.5

@dengnidejijie
Copy link

+1 same error on version 2.3.2

@1474282816
Copy link

same error

@linuxaged
Copy link

have spent almost a full day tracking here. the project I maintain indirectly depends on swr via ant-design/pro-layout, recently got this error when pack, suspecting it had something to do with ESM, CommonJS compatibility. bypassed this by specifying swr to v2.2.5

  // package.json
  "resolutions": {
    "swr": "2.2.5"
  },

@coldJson
Copy link

coldJson commented Apr 3, 2025

same error。umi3 project,import ant-design/pro-componets,show the same error when npm start。the error version of swr is 2.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests