Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Error when building Next.js application due to import issue with styled-components.

12 replies
Last updated: Mar 25, 2024
Hey people! I was migrating from super old sanity-next to the latest version and so far everything works locally but on my github actions when trying to build next-js application I get this error:
   ▲ Next.js 14.1.4

   Creating an optimized production build ...
Failed to compile.

./node_modules/.pnpm/@sanity+ui@2.0.12_62vzzrxnsy3jqmiizpwx4sb5xu/node_modules/@sanity/ui/dist/index.mjs
Attempted import error: 'styled' is not exported from 'styled-components' (imported as 'styled').
Any clue what might be causing this?
Mar 25, 2024, 6:50 PM
Can you try installing
"styled-components": "^6"
Mar 25, 2024, 6:56 PM
just installed before your comment
Mar 25, 2024, 7:03 PM
did not work out
Mar 25, 2024, 7:03 PM
		"next-sanity": "^8.5.0",
		"next-sanity-image": "^6.1.1",
		"sanity": "^3.10.0",
		"sanity-plugin-markdown": "^4.1.0",
Mar 25, 2024, 7:03 PM
I have this setup, maybe it helps with ideas to debug it
Mar 25, 2024, 7:03 PM
as soon as I commented out Studio, next app built just fine
Mar 25, 2024, 7:03 PM
one the side note
user M
, the latest installed styled-components is
"styled-components": "^5.3.11",
Mar 25, 2024, 7:04 PM
Yes, that’s why I asked if you installed
^6
.
Mar 25, 2024, 7:04 PM
trying right now, thanks a lot for being super responsive! much appreciated!
Mar 25, 2024, 7:05 PM
seems like it is flying right now...
Mar 25, 2024, 7:09 PM
thanks a lot
user M
, best ❤️
Mar 25, 2024, 7:09 PM
Glad we got it working! :sanity_with_3_hearts:
Mar 25, 2024, 7:09 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?