-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
create-react-app-with-styled-components fails with Can't resolve '@emotion/react' #27846
Comments
Also tried |
I'm going to work on this Issue.. Can you explain me in brief. |
|
It works after installing |
I understand what's your issue. And I already started working on this. |
Thanks for the report. I can reproduce that it does not work with npm. I tried and it works with yarn. I believe it's related to the package alias we use, namely because of the changes done in #27591. Based on #27088 (comment) I remember that @oliviertassinari tested that it works with npm. Olivier can you verify that it works and maybe share which version of npm you are using? |
|
I have noticed two issues with CRA+npm:
-"@material-ui/styled-engine": "npm:@material-ui/styled-engine-sc@next",
+"@material-ui/styled-engine": "npm:@material-ui/styled-engine-sc@^5.0.0-beta.0",
I would propose we revert #27591 and keep this one open to leverage the "overrides" feature of npm once available. For Next.js I believe we are good. Alternatives: a. warn about npm and ask to use yarn in the demo |
This comment has been minimized.
This comment has been minimized.
Emotion should not be required. You can use yarn if you want to follow the current template.
Agree, will do it tomorrow |
This doesn't work with npm as well :( Need to revert those changes as well |
I ran into this behavior with the 5.0 release, trying to use CRA, npm, and styled-components. Installing What's the current state of this? It sounds like the options are either:
|
I am migrating v4 to v5 and got same error with styled components. It didn't work for me by following the change in https://mui.com/guides/styled-engine/. After checked the repo in https://github.com/mui-org/material-ui/tree/next/examples/create-react-app-with-styled-components, I tried to add the following alias into my webpack config file and it works:
|
@DylanSp @binxiaosyd we try to keep https://github.com/mui-org/material-ui/tree/HEAD/examples/create-react-app-with-styled-components up to date regarding the integrating with You need to add:
It would have been much more easier if npm supported package aliases, but for now, this is the recommended setup. |
I'm facing this issue also with yarn... Any updates on this will be greatly appreciated 🙏 |
I got the same issue as @OPerel, I'm using yarn, I'd like to use |
The style guide instructions still don't work. Did anyone find the fix? |
Having the same issue
Looking for a fix |
Did you try the examples https://github.com/mui-org/material-ui/tree/master/examples |
I was upgrading from v5-beta and encountered same issues where @emotion is required. After several attempts, I |
What fixed for me is I installed |
I am getting this warning in Vercel:
Could this be related? I am seeing |
Same here but with Gatsby. Ofc I tried style guide, adding custom webpack configuration , Problem happens with yarn
|
For me it was the issue that webpack was in subfolder of main project |
This still happens, even after installing the package |
Same here, but when i build a docker image
And
|
for those getting error try this npm install @mui/material @emotion/react @emotion/styled |
@react/emotion is still required for mui? I want to be able to manage themes only with styled-component. This is the main reason I can't adopt mui when I starting many projects. |
Be aware that there are known issues using nextjs + styled-components + @mui/styled-engine-sc, because of the way of how the babel plugin for styled components work:
I would strongly recommend using the default styling engine with emotion. |
Overrides support released in npm v8.3.0. Does it solve the problem now? |
In case this helps anyone else - I had this issue with yarn workspaces. The issue was twofold:
If you inspect |
did you fix this issue? i have same when deploying to Jenkin |
did you fix this issue? i have same when deploying to Jenkin |
For me, I'm using npm, rollup and typescript, and I followed this guide: https://mui.com/material-ui/guides/styled-engine/ tsconfig.json
rollup.config.js
But I still get this error:
|
Still encountering this issue as of today (npm
I was able to get past the issue by following the The MUI Installation docs might need to be updated to reflect that this is necessary. The current docs imply that you need to do EITHER:
OR
...when the actual solution is:
|
I don't know why people closed this issue, but it still happens. I used these instructions: https://mui.com/material-ui/getting-started/installation/ to use MUI with Styled-Components. But my project is failing asking to install '@emotion/react' and '@emotion/styled' for me it does not make sense, since I don't want to use emotion, I just want to use the good and old My package.json:
|
I tried this |
The only way that I could find to "fix" was by installing the Please if you fix this let me know. Thank you so much for the great work |
Bump - ran into this today when following this MUI guide: https://mui.com/x/react-date-pickers/getting-started/ - really don't want to install or use Emotion as I'm already using Styled Components in my project. |
same here, what's going on? |
Put these in package.json
If you do not completely remove node_modules and package-log.json before npm install, |
The styled-components example fails with not finding emotion
Current Behavior 😯
Expected Behavior 🤔
Steps to Reproduce 🕹
Follow the example:
Context 🔦
Your Environment 🌎
`15:50 $ npx @material-ui/envinfo npx: installed 2 in 4.683s
System:
OS: macOS 11.4
Binaries:
Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
Yarn: Not Found
npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
Browsers:
Chrome: Not Found
Edge: 92.0.902.62
Firefox: 90.0.2
Safari: 14.1.1
npmPackages:
@material-ui/core: next => 5.0.0-beta.4
@material-ui/lab: next => 5.0.0-alpha.43
@material-ui/private-theming: 5.0.0-beta.4
@material-ui/system: 5.0.0-beta.4
@material-ui/types: 6.0.2
@material-ui/unstyled: 5.0.0-alpha.43
@material-ui/utils: 5.0.0-beta.4
@types/react: 17.0.19
react: latest => 17.0.2
react-dom: latest => 17.0.2
styled-components: latest => 5.3.0`
The text was updated successfully, but these errors were encountered: