V3 upgrade: "sanity deploy" fails looking for removed sanity.json file

6 replies
Last updated: Feb 22, 2023
Hi all, I've had an issue appear after upgrading to V3. I can't run
sanity deploy
(or
configcheck
) as the following error is returned...

Error: ENOENT: no such file or directory, open '/Users/marks/client-work/surf-simply/surf-simply/studio/sanity.json'

Obviously
sanity.json
haas been removed in favour of
sanity.config.js
so I'm not sure what's looking for that file. Studio is working perfectly locally.
here is the following console warning when running locally...

`Both
@sanity/core
AND
sanity
installed - assuming Sanity v3 project.`
I can't find any reference to
@sanity/core
anywhere in my project though. So, yeah, weird one. V2 to V3 upgrade.
Any help would be really amazing... thank you
πŸ™
AI Update

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.yaml

2. 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 install

5. 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 thread
6 replies
This is probably a long shot but have you tried removing
node_modules
and reinstalling?
Have you also upgraded your CLI to the latest version?
Thank you so much, back up and running! πŸ™‚
Awesome! Good luck with the rest of your migration!
So I just wanted to follow up with a more macro thank you... you're always so helpful
user M
and just make working with dream software like Sanity all the more dreamy. Props to you and the rest of the Sanity team for not only making the best product around but also a community to match. πŸ‘Š
Thank you, User! That means a lot!

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?