V3 upgrade: "sanity deploy" fails looking for removed sanity.json file
This is a classic issue with leftover v2 dependencies after upgrading to v3! The warning message "Both @sanity/core AND sanity installed - assuming Sanity v3 project" is the key clue here.
Even though you can't find @sanity/core directly referenced in your project files, it's likely still installed as a dependency (or transitive dependency) in your node_modules. The CLI is detecting both the old v2 package (@sanity/core) and the new v3 package (sanity), which causes it to behave inconsistently - sometimes looking for the old sanity.json file.
Here's how to fix this:
1. Clean out old v2 dependencies:
# Remove node_modules and lock files
rm -rf node_modules
rm package-lock.json # or yarn.lock / pnpm-lock.yaml2. Look for these old v2 packages in your package.json and remove them:
@sanity/core@sanity/cli(v2 version)@sanity/base@sanity/components@sanity/desk-tool- Any other
@sanity/*packages that aren't needed in v3
3. Make sure you have the v3 package:
Your package.json should have:
{
"dependencies": {
"sanity": "^3.x.x"
}
}4. Reinstall dependencies:
npm install # or yarn / pnpm install5. Verify your CLI configuration:
Make sure you have a sanity.cli.js (or .ts) file in your project root with at least:
import { defineCliConfig } from 'sanity/cli'
export default defineCliConfig({
api: {
projectId: 'your-project-id',
dataset: 'production'
}
})After these steps, sanity deploy should work correctly. The CLI will no longer be confused about which version you're using, and it won't look for the old sanity.json file.
If you're still seeing issues, check if any custom plugins you're using might have @sanity/core as a dependency - those plugins would need to be updated to v3-compatible versions as well.
Show original thread6 replies
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.