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

Troubleshooting issues with using the Sanity CLI on an M1 Mac and finding a workaround.

28 replies
Last updated: Jan 28, 2022
Hey folks! Anyone have any experience using the Sanity CLI with an M1 Mac? I’m trying to resurrect an old project and trying to upgrade all dependencies but it seems like the CLI just doesn’t wanna run. This project was bootstrapped from the Gatsby blog starter
Jan 27, 2022, 10:48 PM
Hey User! This thread from a few days ago might have a solution for you!
Jan 27, 2022, 11:13 PM
Thanks User, seems like that conversation is more about node-gyp? Unless I’m understanding the logs wrong, there’s something wrong with
sanity cli
itself? It always fails to resolve dependencies. I’ve tried running it from both the root folder as well as the studio folder
Jan 27, 2022, 11:22 PM
In the meantime, is there a workaround to updating studio dependencies without the CLI?
Jan 27, 2022, 11:26 PM
It looks like you haven't installed Sanity based off of that error. If you cloned a repo or are working directly from the create flow for the starter, did you run
npm i
before trying to run
sanity install
If that isn't the case, the only other report I've seen of folks having issue with the Studio on an M1 is that thread I shared, so I would think it's unlikely an issue with the CLI and more an issue with your particular machine. I could be wrong though! In particular, did you
read this reply to the thread I shared describing how they got the same starter to work on their M1?
Jan 27, 2022, 11:33 PM
From my own experiences with node on the m1, I would suggest uninstalling node (and related package managers) and avoid the homebrew install, which defaults to node v17 and installs into the /lib/homebrew directory.
I’ve installed nvm (via homebrew) and use the current v16 LTS for best results on my m1.

You’ll then want to install the latest cli with
npm install -g @sanity/cli
- and you should not need to use sudo for any of this if you have the xcode tools needed when you installed homebrew.
Jan 28, 2022, 12:39 AM
I may advise also installing yarn.

npm install --global yarn
Jan 28, 2022, 12:40 AM
I’m sure someone out there has a more elegant solution to my own ‘nuke it from orbit and re-install via effectively another third party package manager’ method, but at least this keeps all node services within the same family and has worked well for me.
Jan 28, 2022, 12:42 AM
Yup, I ran
npm i
from the root directly and that ran just fine. I’ve had issues with node in the past, when I first initially tried to install node. Not entirely sure what I ended up doing to finally getting it to work. I’m not super well versed with node and nvm,
user S
, is there a guide I can follow to properly uninstall and reinstall node through
Jan 28, 2022, 12:55 AM
user S
I just ran
npm i
in studio and then tried
sanity install
again and it returns the same thing. Perhaps it is indeed something with brew
Jan 28, 2022, 12:58 AM
user S
I just ran
npm i
in studio and then tried
sanity install
again and it returns the same thing. Perhaps it is indeed something with brew
Jan 28, 2022, 12:58 AM
I believe you can uninstall node using
nvm deactivate
nvm uninstall <your-version-number>
. Then to reinstall you would run
nvm install --lts
Jan 28, 2022, 1:06 AM
Just uninstalled and reinstalled the LTS using NVM. Reinstall Sanity CLI and then
npm install
and then finally
sanity install
and I’m still getting the same issue 😞
Jan 28, 2022, 1:22 AM
This issue can be pretty frustrating because one has to balance multiple repo services, the operating system quirks, and the project build. I feel your pain with all of this.
Since your error still appears to be looking in
for the sanity cli, I would bet that this is because:a. your previous node install with homebrew wasn’t completely removed and/or
b. the node_module data in that repo is now out of date and should be deleted and rebuilt

My personal approach if this was my machine would be:
1. try
brew remove node
again, then
brew doctor
, fix any outstanding issues if any then reboot to be sure2. we want to continue removing ‘cached’ data. in your studio directory, run
rm -rf node_modules
this dir should be safe to remove3. set asside recovery of this studio build and start a new studio install to test.
• check
node -v
to see if it’s still correct• run
npm install -g @sanity/cli
again to be sure it’s installed • run
sanity -h
to test that the cli path is correct, you should see some basic available commands• create a new directory
mkdir ~/test && cd ~/test
, then
sanity login
, then
sanity init
• create a new test project, you can use one of the starter schemas here too
• log into
https://www.sanity.io/manage and you should see the new test project and your existing one4. run
sanity install && sanity start
on your new test studio - this should work if you’ve made it this far. Now you have an existing working and updated schema. You can try
sanity install
on your existing studio build. You can also swap in your existing projectId and dataset into the new studio install (in sanity.json) and use the vision tool to browse any data or just swap in your previous schema builds to the new studio install.
Jan 28, 2022, 2:43 AM
Another tip, if you’ve recovered this studio build from git from an old pc or intel mac to a new m1, make sure that you weren’t syncing node_modules to your repository. If node_modules made it into your repository, you will want to clean this out (
git rm -r node_modules
then git add/push to remove them from the remote repo)
Jan 28, 2022, 2:47 AM
user S
, thank you so much for taking the time to help me debug this and writing out all those detailed steps. I’ve followed along but it’s still failing specifically at the “Resolving Dependencies” stage. Now it’s complaining about the something in
Jan 28, 2022, 3:09 AM
It is acting like sanity-cli isn’t installed. Do you get anything back when you enter
sanity versions
Jan 28, 2022, 3:12 AM
It keeps complaining about running
sanity install
but never actually lets me successfully run it because it fails at the dependency stage
Jan 28, 2022, 3:13 AM
ignore my commandline tweaks - here is why my current node environment looks like on my m1• and in a working studio install I’m playing with now
Jan 28, 2022, 3:22 AM
Seems like those are all the latest versions of the dependencies. Now if I could only get sanity-cli to install…
Back to one of my earlier questions, is there a workaround to installing these without sanity-cli?
Jan 28, 2022, 4:09 AM
Just in case this is helpful:
Jan 28, 2022, 4:49 AM
There might be an error in a package.json or a lockfile or something that could be causing issues - sorry about the lack of details in that error message
Jan 28, 2022, 5:28 AM
Interesting, so by extension
sanity upgrade
is just
npm upgrade
? All I’m trying to do is run a upgrade all on the dependencies so I can start working on the project. If I can avoid sanity-cli altogether, I can just do that
Jan 28, 2022, 4:55 PM
Alright, seems like I just needed to do
npm install
and now sanity cli doesn’t complain anymore. And is happy to resolve dependencies now! So weird.
Jan 28, 2022, 4:56 PM
I’m so happy things seem to be working now, User. I’m pretty fascinated about how much repo and tooling management is or isn’t taught to new developers, as I’ve had to dig into a lot of this on my own time between classes and work experience. Thanks for bearing with me with our little back and forth to get you working.
Jan 28, 2022, 10:36 PM
Thank you
user S
, I really appreciate you taking the time to help me debug this. I should be the one thanking you! I’m actually a designer, and a 100% self taught developer, so I likely have large gaps than more new/junior developers. Perhaps one day I’ll find the time to learn this and git to a decent extent!
Jan 28, 2022, 11:47 PM
I’d mention that while sanity cli wasn’t complaining anymore, it might’ve had something to do with just bypassing it overall and using
. I just tried running
sanity install @sanity/color-input
and it threw up that same error. Managed to
npm install @sanity/color-input
just fine.
Jan 28, 2022, 11:48 PM
oh that is really frustrating - I’m not actually suggesting this, but I have a personal habit of backing up and defaulting then manually recovering my desktop OS. I keep a list of repos and apps to reinstall, manually move over big media or game directories. And some day I’ll have a fully working dotfile management system for myself. As I find these little quirks and methods, it helps keep config files clean and helps get me back on my feet faster when inevitable tooling issues like this crop up.
You may want to research some dotfile and dev tools management methods to help, along with tools like iterm2 and omz — but that is only a personal suggestion and strictly on you if you’re interested.
Jan 28, 2022, 11:55 PM
Thanks, I’ll definitely look into it when I get the chance!
Jan 28, 2022, 11:57 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?