[gatsby-plugin-styled-components] Can't resolve 'react-is' #31912
-
Description3:34:32 PM: failed Building production JavaScript and CSS bundles - 40.804s Steps to reproduceThis error only occurs during build. I was not able to reproduce the issue with I updated gatsby, all gatsby plugins, and styled-components to the latest version but the error persists. The latest gatsby styled-compoents documentation includes the installation of a babel plugin which I was missing. I installed it now but the error persists:
I cloned the gatsby styled-components starter but I was not able to replicate the error running build locally. Workaround: I added react-is to my dependencies manually which resolved the issue. But I guess that's not a desired fix. Any help is highly appreciated! Expected resultBuild runs through Actual resultBuild fails Environmentbabel-plugin-styled-components: ^1.12.0 System: |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 2 replies
-
Did you maybe forget to import react? |
Beta Was this translation helpful? Give feedback.
-
Hey John! I just checked all my recently created / changed components in the last commits and I am fairly confident that all components import React. Also, eslint goes nuts if I do remove React from one component and once I try to render the specific page, Gatsby throws "React is not defined". I am fairly confident that I would have discovered this. |
Beta Was this translation helpful? Give feedback.
-
Maybe since react got a new update your version of react is not up to date so could you try updating it ? |
Beta Was this translation helpful? Give feedback.
-
Both react and react-dom are at latest!
|
Beta Was this translation helpful? Give feedback.
-
Try doing "npm list react" and show me what it looks like. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help! So you are thinking it's a react mismatch that prompts this issue? npm list react:
|
Beta Was this translation helpful? Give feedback.
-
Probably, I have seen this issue often recently I think it's because you have a corrupted Node environment on your machine. I would suggest wiping the plugin-sample and start again (or at least remove the node_modules and package-lock.json. I have seen this work but don't take my word for it. |
Beta Was this translation helpful? Give feedback.
-
This is a problem with your local installation. As John said it can help if you nuke node_modules/package-lock.json and redo the install. Maybe also try the |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your support, I really appreciate the explanations! I will figure this out then. Sad thing is, it also happens on my Netlify build pipeline but I have had similar experiences with the pipelines in the past, even after clearing the cache. I might try to force a nodejs version on Netlify and see how that works out. I hope this thread pops up for others having similar issues, so it provides guidance for others as well! |
Beta Was this translation helpful? Give feedback.
Probably, I have seen this issue often recently I think it's because you have a corrupted Node environment on your machine. I would suggest wiping the plugin-sample and start again (or at least remove the node_modules and package-lock.json. I have seen this work but don't take my word for it.