Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Error when running `sanity deploy` after upgrading project versions

8 replies
Last updated: Jun 17, 2024
Hey everyone! I just upgraded a project of mine from v2 and v3 and everything is working locally and the build is previewing locally as well. However, when I run
sanity deploy
, i'm getting the following error:
Error: sanity.cli.js does not contain a project identifier ("api.projectId"), which is required for the Sanity CLI to communicate with the Sanity API
Even though there is a
sanity.cli.js
in the root of the directory that looks like this:
import { defineCliConfig } from "sanity/cli"

export default defineCliConfig({
	api: {
		projectId: "my_project_id",
		dataset: "production",
	},
})
Anyone else hit this when upgrading? I also am getting a message in the terminal that I installed the nodes on the intel chip versus my m1 even though I've deleted my
node_modules
and re-run
npm i
. Don't know if they are connected. Thanks in advance for and help!
Apr 1, 2024, 4:56 PM
What version of the CLI is used when you run
sanity --version
?
Apr 1, 2024, 5:00 PM
Hey Geoff! Thanks for the response. I'm using 3.11.5
Apr 1, 2024, 5:04 PM
Could you please try running
npx sanity deploy
, which will ask to download and then use the latest version (without impacting the version you have installed)?
Apr 1, 2024, 5:08 PM
That seemed to do the trick, but did not ask to download anything. Thank you for your help!
Apr 1, 2024, 5:10 PM
Great! In that case, it’s possible there was a change in there somewhere, and upgrading your global install of the CLI (
npm i -g @sanity/cli
) should let you run
sanity deploy
without getting that error.
Apr 1, 2024, 5:12 PM
Thanks Geoff! Have a great day
Apr 1, 2024, 5:13 PM
You too! 🙌
Apr 1, 2024, 5:15 PM
Hey
user A
I'm experiencing this error at the moment.
I'm using
@sanity/cli version 3.16.7

sanity.cli.js file looks like this:

 /* eslint-disable no-process-env */
import { projectId, dataset } from './sanity.config.js'
import {defineCliConfig} from '/sanity/cli'

export default defineCliConfig({api: {projectId, dataset}})
And
npx sanity deploy
isn't quite doing the trick:
Error: sanity.cli.js does not contain a project identifier ("api.projectId"), which is required for the Sanity CLI to communicate with the Sanity API

Do you have any other ideas of how to debug this?
Thanks :)
Jun 17, 2024, 3:26 AM

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?