๐Ÿ‘€ Our most exciting product launch yet ๐Ÿš€ Join us May 8th for Sanity Connect

Error in Sanity CLI configuration and deployment, resolved with the addition of a missing file.

29 replies
Last updated: Dec 13, 2022
๐Ÿ‘‹ Hello, team! can you please help me with this 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
Dec 13, 2022, 7:25 PM
Hello! yes you need to include your project Id and the name of your dataset. You can find them in your sanity.json in the api brackets
Dec 13, 2022, 7:32 PM
Or index.js/ts if you are using V3!
Dec 13, 2022, 7:38 PM
i have cloned leerob portfolio, i dont see any of that file
Dec 13, 2022, 7:38 PM
do you ahve the repo
Dec 13, 2022, 7:38 PM
Dec 13, 2022, 7:39 PM
yes I have added project id there.
Dec 13, 2022, 7:40 PM
i'm not sure how he deployed the sanity studio, or if he has deployed or not?curious.
Dec 13, 2022, 7:45 PM
run
sanity deploy
Dec 13, 2022, 7:45 PM
how is your package.json?
Dec 13, 2022, 7:47 PM
wait a minute, let me try and add sanity deploy command here
Dec 13, 2022, 7:49 PM
still same error
Dec 13, 2022, 7:50 PM
in your config.
import { ~createConfig~ } from 'sanity;
Why is it crossed over?
Dec 13, 2022, 7:52 PM
it is deprecated, its now defineconfig
Dec 13, 2022, 7:52 PM
maybe try switching to defineConfig?
Dec 13, 2022, 7:53 PM
tried just now, still
Dec 13, 2022, 7:53 PM
copy paste the whole config here
Dec 13, 2022, 7:54 PM
import { createConfig } from 'sanity';import { deskTool } from 'sanity/desk';
import { markdownSchema } from 'sanity-plugin-markdown';

export default createConfig({
name: 'default',
title: 'rahulbiz',
projectId: 'lmj8mowy',
dataset: 'production',
plugins: [deskTool(), markdownSchema()],
schema: {
types: [
{
name: 'post',
type: 'document',
title: 'Post',
fields: [
{
name: 'title',
title: 'Title',
type: 'string'
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title'
}
},
{
name: 'content',
title: 'Content',
type: 'markdown'
},
{
name: 'excerpt',
title: 'Excerpt',
type: 'string'
},
{
name: 'coverImage',
title: 'Cover Image',
type: 'image'
},
{
name: 'date',
title: 'Date',
type: 'datetime'
}
]
},
{
name: 'snippet',
type: 'document',
title: 'Snippet',
fields: [
{
name: 'title',
title: 'Title',
type: 'string'
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title'
}
},
{
name: 'content',
title: 'Content',
type: 'markdown'
},
{
name: 'description',
title: 'Description',
type: 'string'
},
{
name: 'logo',
title: 'Logo',
type: 'image'
}
]
}
]
}
});
Dec 13, 2022, 7:55 PM
but now you sent with createConfig?๐Ÿ˜…
Dec 13, 2022, 7:57 PM
ah i just did ctrl+z
Dec 13, 2022, 7:57 PM
Whatโ€™s inside your .sanity folder?
Dec 13, 2022, 7:59 PM
that is when I run sanity dev, generated file on local server
Dec 13, 2022, 8:01 PM
With a sanity.cli.js file inside?
Dec 13, 2022, 8:02 PM
no no
Dec 13, 2022, 8:03 PM
๐Ÿคทโ€โ™‚๏ธ Then i dont know
Dec 13, 2022, 8:03 PM
thank you for your time
Dec 13, 2022, 8:05 PM
hey
user U
i figured it out, there should be a file with that name and the details inside it
Dec 13, 2022, 8:28 PM
but now my sanity studio is deployed whenever I am publishing my content its not getting visible on website.
Dec 13, 2022, 8:29 PM
please close this, everything is working fine.
Dec 13, 2022, 8:31 PM

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?