Trouble updating Sanity version, seeking help and guidance.

21 replies
Last updated: Jan 24, 2024
I have been away for the last couple of months dealing with family stuff, and now I have come back feeling like I can't remember how to do anything work-related, HA! Anyway, I am trying to update our Sanity from 3.19.3 to 3.26.0 and I can not, for the life of me, remember what the command is to update it, and I can't find it anywhere. Doing
npm update sanity
does not update to 3.26.0. I feel so silly and like the answer is obvious and right in front of me, but my brain just can't see it. 🤦‍♀️ Can someone please put me out of my misery here?!
AI Update

Don't worry, we've all been there! Welcome back, and I hope things are better with your family 🙂

The command you're looking for is:

npm install sanity@latest

This will update Sanity to the latest version (3.26.0 in your case). The reason npm update doesn't work is that it respects the version range in your package.json, so it's probably staying within whatever semver range is specified there (like ^3.19.3).

You can also use the Sanity CLI command:

sanity upgrade

Or if you don't have the CLI installed globally:

npx -y sanity@latest upgrade

The sanity upgrade command is smart about respecting version ranges and selectively upgrading Sanity-related packages while leaving other dependencies alone. It'll also show you a prominent message if there are major updates available with links to the changelog.

After running either command, restart your dev server and you should be good to go!

You may have
3.19.3
locked into your package.json. changing it to
^3.19.3
will allow the update
nope, it's
"sanity": "^3.19.3"
😞 I have been updating sanity studio for the last two years with a simple command (that used to be noted under the version number when you needed to update), and I can't believe I have completely wiped it from my memory.
Have you tried removing your node_modules and lock file?
I will give that a shot. Is the command just
npm update sanity
?
You can run npm outdated to see if its outdated as well.
No luck.
When I do
npm outdated
, this is what I get.
And my dependencies in my package.json look like this:
try:

npm view sanity version

If you deleted your modules folder and lock file you’d run
npm i
to get everything loaded up again.
when i ran npm view sanity version it said 3.26.0 .... whaaaat
Success?
but... my package.json still says 3.19, and when I spin up the dev server it says it's 3.19
You may need to delete your lock file and
node_modules
and then run
npm i
I deleted the node_modules and did npm install after that, but I didn't delete the lock file. So I will do it again and delete the lock file this time
Your pgk.json saying
^3.19.3
means load up the most current version up to
4
oh I got ya
So it’ll load 3.26 but it won’t say so in the pkg.
ok, I spun up the dev server and it says it is 3.26. Thank you for your help on that. I feel like I have to relearn everything, ha!
But I did see something odd that I want to ask you about while you're still here... why is it saying the latest version is 3.21.1?
when, in prod it looks like this (I haven't pushed my changes to prod yet)
Very good question. My best guess is caching .
ok, I won't worry about it then. :simple_smile:

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?