👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

Troubleshooting a package hoisting issue during a Sanity upgrade

41 replies
Last updated: Jan 5, 2022
Huh, just upgraded Sanity version and got this. Any ways around this?
Aug 28, 2021, 2:06 AM
Hi Toms. Could you please try deleting your
node_modules
folder, installing with yarn or npm, and then trying
sanity start
once more?
Aug 28, 2021, 2:21 AM
Tried that, didn't help.Tried that + removing yarn.lock, didn't help.


😞
Aug 28, 2021, 12:16 PM
Tried that, didn't help.Tried that + removing yarn.lock, didn't help.


😞
Aug 28, 2021, 12:16 PM
Okay, this is a monorepo and this probably doesn't help it:
Aug 28, 2021, 2:58 PM
For whatever reason, the package hasn't been fully hoisted.
Aug 28, 2021, 2:58 PM
Does
yarn list styled-components
show different versions between the top-level styled-components and the one used by
@sanity/base
?
Aug 28, 2021, 3:13 PM
Does
yarn list styled-components
show different versions between the top-level styled-components and the one used by
@sanity/base
?
Aug 28, 2021, 3:13 PM
E.g.,
├─ @sanity/base@2.17.1
│  └─ styled-components@5.3.1
└─ styled-components@5.1.0
Aug 28, 2021, 3:14 PM
nop, yarn list only shows one, the "hoisted one"
Aug 28, 2021, 3:15 PM
because noticed in console that being the first warning:
Aug 28, 2021, 3:16 PM
im not using styled components myself, it's all just Sanity stuff
Aug 28, 2021, 3:17 PM
Did you upgrade to 2.17.1? Do you happen to recall the previous version you were on?
Aug 28, 2021, 3:17 PM
I upgraded to 2.17.1, yes.
Aug 28, 2021, 3:18 PM
1.x something previously, rather old system
Aug 28, 2021, 3:18 PM
Ahh, perfect. Thank you. I have to go out for a bit but will keep trying to replicate and troubleshoot when I get back.
Aug 28, 2021, 3:19 PM
Much appreciated, gotta deploy on monday, lol. 😄
Aug 28, 2021, 3:19 PM
will revert for the time being as im blocked 😞
Aug 28, 2021, 3:20 PM
Unfortunately, I haven’t been able to replicate the error. I used the Commerce Layer monorepo to try and emulate your setup—starting on 1.150.8 and upgrading to 2.17.1. I’ll ask the team for some advice and recognize that the upgrade is on a deadline.
Aug 29, 2021, 4:24 PM
I’ve been able to replicate your error now, by manually adding styled-components@5.1.0 to the studio folder. I could then solve it by removing styled-components or upgrading it to the same version as what’s being used by the @sanity packages. Based on your screenshots of previous efforts I’m still not entirely sure how to solve this, since your setup doesn’t appear to have that same duplication. I’m admittedly no expert with modules but perhaps you could search your lock file for styled-components and see if there’s another version somewhere.
Aug 29, 2021, 5:08 PM
Oh, you know what else is specific to my env, my monorepo has two studio installations.
Aug 29, 2021, 5:14 PM
Oh, you know what else is specific to my env, my monorepo has two studio installations.
Aug 29, 2021, 5:14 PM
Both of them were in the same version though.
Aug 29, 2021, 5:14 PM
While reverting I didn't save ones package.json so one was on 1.x and the other in 2.x, that worked.
Aug 29, 2021, 5:15 PM
But I'm not so sure if they both were the exact same version, maybe I messed up somewhere.
Aug 29, 2021, 5:16 PM
So while the two were on different versions it worked? Or it works now?
Aug 29, 2021, 5:22 PM
On different worked
Aug 29, 2021, 6:02 PM
On different worked
Aug 29, 2021, 6:02 PM
As only one of them had the new UI
Aug 29, 2021, 6:02 PM
On different worked
Aug 29, 2021, 6:02 PM
If both are on 2.17.1 and you install styled-components ^5.2.1, does that work?
Aug 31, 2021, 6:16 AM
I'll get back to you when I have time to test. Thanks for your time already!
Sep 1, 2021, 7:11 PM
I'll get back to you when I have time to test. Thanks for your time already!
Sep 1, 2021, 7:11 PM
Hi Toms. I just wanted to follow up and see how things are going with this. I believe a fix should be available on the next release to resolve this issue with yarn/npm’s occasional reluctance to properly hoist packages, and wanted to let you know so you can keep an eye out.
Sep 8, 2021, 2:04 PM
Oh, great news! I've been busy with other stuff and haven't invested any more time to upgrade. Still on 1.150.8ish.
Sep 8, 2021, 2:07 PM
You got PR to link so I can see what's the fix like?
Sep 8, 2021, 2:08 PM
thanks! subscribed to releases
Sep 10, 2021, 10:53 AM
Hi Toms. This will hopefully be resolved by 2.19.0, just released.
Sep 13, 2021, 1:56 PM
Hey, a bit late, but I just upgraded my sanity instances and it all works now, thanks!
Jan 5, 2022, 12:41 PM
Awesome! Thanks for letting us know! 🙌
Jan 5, 2022, 6:02 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?