Error in Sanity CLI configuration and deployment, resolved with the addition of a missing file.
29 replies
Last updated: Dec 13, 2022
R
👋 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
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
A
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
H
Or index.js/ts if you are using V3!
Dec 13, 2022, 7:38 PM
R
i have cloned leerob portfolio, i dont see any of that file
Dec 13, 2022, 7:38 PM
H
do you ahve the repo
Dec 13, 2022, 7:38 PM
R
Dec 13, 2022, 7:39 PM
H
sanity.config.ts https://github.com/leerob/leerob.io/blob/main/sanity.config.ts
Dec 13, 2022, 7:39 PM
R
yes I have added project id there.
Dec 13, 2022, 7:40 PM
R
i'm not sure how he deployed the sanity studio, or if he has deployed or not?curious.
Dec 13, 2022, 7:45 PM
H
run
sanity deploy
Dec 13, 2022, 7:45 PM
H
how is your package.json?
Dec 13, 2022, 7:47 PM
R
wait a minute, let me try and add sanity deploy command here
Dec 13, 2022, 7:49 PM
R
still same error
Dec 13, 2022, 7:50 PM
H
in your config.
import { ~createConfig~ } from 'sanity;Why is it crossed over?
Dec 13, 2022, 7:52 PM
R
it is deprecated, its now defineconfig
Dec 13, 2022, 7:52 PM
H
maybe try switching to defineConfig?
Dec 13, 2022, 7:53 PM
R
tried just now, still
Dec 13, 2022, 7:53 PM
H
copy paste the whole config here
Dec 13, 2022, 7:54 PM
R
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'
}
]
}
]
}
});
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
H
but now you sent with createConfig?😅
Dec 13, 2022, 7:57 PM
R
ah i just did ctrl+z
Dec 13, 2022, 7:57 PM
H
What’s inside your .sanity folder?
Dec 13, 2022, 7:59 PM
R
that is when I run sanity dev, generated file on local server
Dec 13, 2022, 8:01 PM
H
With a sanity.cli.js file inside?
Dec 13, 2022, 8:02 PM
R
no no
Dec 13, 2022, 8:03 PM
H
🤷♂️ Then i dont know
Dec 13, 2022, 8:03 PM
R
thank you for your time
Dec 13, 2022, 8:05 PM
R
hey
user U
i figured it out, there should be a file with that name and the details inside itDec 13, 2022, 8:28 PM
R
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
R
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.