You are loading @emotion/react when it is already loaded. Running multiple instances may cause problems. This can happen if multiple versions are used, or if multiple builds of the same version are used. #2795
Replies: 18 comments 33 replies
-
Are there multiple copies of |
Beta Was this translation helpful? Give feedback.
-
I tried
|
Beta Was this translation helpful? Give feedback.
-
I also don't have a single copy of |
Beta Was this translation helpful? Give feedback.
-
I'm also seeing this silly warning while running
I would suggest to just remove the warning. Users are not in control of indirect dependencies and suggesting to modifying lockfiles directly is also not really something anyone should ever do. |
Beta Was this translation helpful? Give feedback.
-
Anyone came up with solution other than deleting package-lock.json/yarn-lock.json file? |
Beta Was this translation helpful? Give feedback.
-
I had the same warning before but didn't find more than one version of @emotion/react in my node_modules folder.
I was able to disable the warning when I included the @emotion/babel-plugin in my .babelrc file. .babelrc {
...
"plugins": [
...
"@emotion/babel-plugin"
]
} |
Beta Was this translation helpful? Give feedback.
-
If you are stumbling upon this thread in hope of finding an answer as to why you're seeing this, despite only having one version (even deduped) with I found that this was being emitted because we had an app with vite running esm, loading via esm, then a package we were using was using cjs, which then loaded emotion again via the cjs bundle, thus emitting this warning. Fixing the package exports and generated sources to have both esm and cjs resolved this warning 🚀 |
Beta Was this translation helpful? Give feedback.
-
I am seeing this when running a micro frontend setup, using webpack federated modules. |
Beta Was this translation helpful? Give feedback.
-
I too am getting this warning with my micro frontend that uses vite (which has emotion/react listed in peer and dev dependencies) as components package and NextJs 12 (emotion/react as dependencies) as main. |
Beta Was this translation helpful? Give feedback.
-
Hello folks, I am seeing the same issue. But my versions are all the same. Can anyone throw some insights?
|
Beta Was this translation helpful? Give feedback.
-
If you're receiving this message and don't have multiple versions of If this is your case, you are using webpack, and you have access to
For
I think you might want to change up the order to Keep in mind that this configuration will be applied to all packages. I'm not sure if you can do it in a non-global way. @dbashford @salehkaddoura-alation, this might interest you. I'm unsure if the vite option works in the same way, but it might have something similar. |
Beta Was this translation helpful? Give feedback.
-
It happened to me today. I'm have Vite + react + emotion/styles,react in pnpm workspace monorepo setup. This is what worked:
Pretty sure 2 + 3 got rid of the warning for me. |
Beta Was this translation helpful? Give feedback.
-
an easy way for CRA just add this to your package.json:
this will force all submodules to use this specific version. |
Beta Was this translation helpful? Give feedback.
-
In my project, I was able to fix the warning by setting emotion/packages/react/src/index.js Line 20 in 1c60314 |
Beta Was this translation helpful? Give feedback.
-
Thanks to the answers above for helping me debug this. In my case I only have one copy of Emotion in my package-lock.json and it only showed up with one entry in In my
This fools Emotion into thinking that it's already loaded, so you get a console warning from the first version of Emotion to load too. This makes it very easy to place breakpoints where the warning is emitted. Reload the page, and you can see the backtrace for how Emotion is getting loaded. In my case, it was |
Beta Was this translation helpful? Give feedback.
-
ViteJS config that fixes the error: resolve: {
dedupe: ['@emotion/react']
} |
Beta Was this translation helpful? Give feedback.
-
I just recently struggled with this issue. I think it was caused by some npm packages using the
module.exports = {
resolve: {
alias: {
'@emotion/react': path.resolve(__dirname, 'node_modules/@emotion/react'),
},
}
} |
Beta Was this translation helpful? Give feedback.
-
Current behavior:
I get this warning:
You are loading @emotion/react when it is already loaded. Running multiple instances may cause problems. This can happen if multiple versions are used, or if multiple builds of the same version are used.
I also get a quick flickr where all my styles on the page are messed up when I first load a page, I believe this is from one instance of
@emotion/react
loading, then another instance loading and overwriting the styles of the previous instance.To reproduce:
npx create-next-app --example with-typescript reproduction
_app.tsx
file in your/pages
folder and add:http://localhost:3000
and check console for warningI'm aware the code example above mixes component libraries (which is usually bad practice and a big no no), but what if I want to use a React component from a library that uses
@emotion/react
? I would get the same issue since Chakra UI uses@emotion/react
too and they would overwrite each other. How do I fix this? Is there a way to use several instances and choose which instance overwrites the other? Is it possibly to also have the styles (that don't overwrite) unionize with the other instance's styles? I know I have a lot of questions, but I'm looking for a workaround for this issue without having to choose a different library that doesn't use@emotion/react
, someone please help, thanks so much.Expected behavior:
Normal loading with no CSS flickr and no warning
Environment information:
react
version: 17.0.2@emotion/react
version: ^11.9.3Beta Was this translation helpful? Give feedback.
All reactions