
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe "sanity: command not found" error on Vercel happens because the Sanity CLI isn't properly installed in your build environment, even though it works locally. Here's how to fix it:
Your build script uses npx sanity build, but Vercel doesn't have access to the Sanity CLI because:
dependencies (not devDependencies)/studio foldercd studio command might not be executing in the context you expectIn your studio/package.json, make sure @sanity/cli and @sanity/core are in dependencies:
{
"name": "studio-project",
"scripts": {
"start": "sanity start",
"build": "sanity build"
},
"dependencies": {
"@sanity/cli": "^3.x.x",
"@sanity/core": "^3.x.x",
// ... other dependencies
}
}Important: Vercel doesn't install devDependencies in production builds, which is why your local setup works but Vercel fails.
In your root package.json, modify the build script to ensure dependencies are installed:
"scripts": {
"build": "npm run build:sanity && next build",
"build:sanity": "cd studio && npm install && npx sanity build ../public/studio -y && cd .."
}Or reference the build script in your studio's package.json:
"build:sanity": "cd studio && npm run build && cd .."Add a prebuild script that runs before the main build:
"scripts": {
"prebuild": "cd studio && npm install",
"build": "npm run build:sanity && next build",
"build:sanity": "cd studio && sanity build ../public/studio -y"
}If you don't need the Studio bundled with your Next.js app, consider using sanity deploy instead:
cd studio && sanity deployThis deploys your Studio to yourproject.sanity.studio and eliminates the complexity of bundling it with your frontend. Many teams find this approach cleaner and it's the recommended deployment method because it:
If you're using a monorepo structure, check your Vercel project settings:
npm install && cd studio && npm installThe key takeaway: Production build tools don't install devDependencies, so make sure @sanity/cli is in your regular dependencies in the studio/package.json file.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store