How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

npm install Sanity CLI but "command not found: sanity" error

11 repliesLast updated: Nov 30, 2025

Hello everyone, I just can’t get the sanity cli up and running.
After typing in

npm install -g @sanity/cli
I only get the following output

changed 1 package, and audited 2 packages in 2s

found 0 vulnerabilities
after typing in
sanity
I get the following error message
zsh: command not found: sanity
AI Update

This is a common issue on macOS with zsh! The problem is that npm's global binary directory isn't in your $PATH environment variable, so your shell can't find the sanity command.

Based on this community discussion about the exact same issue, the recommended solution is to use NVM (Node Version Manager) to manage your Node.js installation.

The Solution: Use NVM

Now the sanity command should work in any new terminal window!

Why This Happens

When you install Node.js directly (not through NVM), the npm global binary path sometimes doesn't get properly added to your shell's $PATH. This is especially common on macOS with zsh. NVM handles this path configuration automatically and also makes it easier to manage multiple Node.js versions.

Alternative Quick Fix (Without NVM)

If you prefer to stick with your current Node.js installation, you can manually add the npm bin directory to your PATH:

However, using NVM is generally more reliable and is the approach recommended by the Sanity community for avoiding these types of PATH issues. Note that Sanity Studio v4 requires Node.js 20 or higher, so you'll want to use a recent Node version anyway.

Show original thread
11 replies

Was this answer helpful?

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.

Related contributions