🎤 Builder Talk: The Story Behind Lady Gaga’s Digital Experience – Register now

Discussion about resolving an error in setting up a custom desk structure in Sanity.io

42 replies
Last updated: Mar 26, 2021
Hey everyone! I was just trying to setup a custom desk strcuture following this article here: https://www.sanity.io/guides/getting-started-with-structure-builder But I always get this error:
Any ideas? Thanks!
Mar 26, 2021, 10:03 AM
This is my `deskStructure.js`:

import S from "@sanity/desk-tool/structure-builder";

export default () =>
  S.list()
    .title("Content")
    .items([
      S.listItem()
        .title("Settings")
        .child(
          S.document().schemaType("siteSettings").documentId("siteSettings")
        ),
      ...S.documentTypeListItems(),
    ]);
Mar 26, 2021, 10:04 AM
Which version are you on,
user N
?
Mar 26, 2021, 10:09 AM
hey
Mar 26, 2021, 10:10 AM
uhm
Mar 26, 2021, 10:10 AM
"dependencies": {
    "@sanity/base": "^2.7.1",
    "@sanity/components": "^2.2.6",
    "@sanity/core": "^2.7.1",
    "@sanity/dashboard": "^2.7.0",
    "@sanity/default-layout": "^2.7.1",
    "@sanity/default-login": "^2.7.0",
    "@sanity/desk-tool": "^2.7.1",
    "@sanity/structure": "^2.7.1",
    "@sanity/vision": "^2.7.0",
    "prop-types": "^15.7",
    "react": "^17.0",
    "react-dom": "^17.0"
  },
Mar 26, 2021, 10:10 AM
this?
Mar 26, 2021, 10:10 AM
Is that not a weird require to have a ? At the end?
Mar 26, 2021, 10:17 AM
It's like that on next branch.
Mar 26, 2021, 10:17 AM
Hey man. what do you mean?
Mar 26, 2021, 10:18 AM
How does your
sanity.json
look like?
Mar 26, 2021, 10:19 AM
{
  "root": true,
  "project": {
    "name": "Minoo Website"
  },
  "api": {
    "projectId": "ab10er4l",
    "dataset": "production"
  },
  "plugins": [
    "@sanity/base",
    "@sanity/components",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/desk-tool"
  ],
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema.js"
    },
    {
      "name": "part:@sanity/desk-tool/structure",
      "path": "./deskStructure.js"
    }
  ]
}
Mar 26, 2021, 10:20 AM
Did you recently add the
@sanity/structure
package and forgot to
npm i
?
Mar 26, 2021, 10:25 AM
npm? I have a yarn.lock..
Mar 26, 2021, 10:25 AM
OK. Did you recently add
@sanity/structure
manually in your
package.json
and not run
yarn
?
Mar 26, 2021, 10:26 AM
also where would I add
@sanity/structure
?
Mar 26, 2021, 10:26 AM
ah .. no i dont think so
Mar 26, 2021, 10:26 AM
hm maybe? I was trying to get rid of this error and might have done something like
sanity install @sanity/structure
Mar 26, 2021, 10:27 AM
try removing your
node_modules
and run
sanity install
again.
Mar 26, 2021, 10:28 AM
😕
Mar 26, 2021, 10:30 AM
Your
deskStructure.js
file is on your root?
Mar 26, 2021, 10:34 AM
Sanity is in
/studio
and this is the directory strcuture in there:
Mar 26, 2021, 10:35 AM
OK. That should be fine.Could you try removing
@sanity/structure
as a direct dependency, remove
node_modules
and to
sanity install
again?
Mar 26, 2021, 10:36 AM
hold on 🙂
Mar 26, 2021, 10:37 AM
Meeehhh..
Mar 26, 2021, 10:39 AM
so sorry man thanks for taking the time
Mar 26, 2021, 10:39 AM
No worries, I'm here to help. 🙂
Mar 26, 2021, 10:40 AM
my
package.json
looks like this now:

{
  "name": "minoowebsite",
  "private": true,
  "version": "1.0.0",
  "description": "",
  "main": "package.json",
  "author": "Nils Borgböhmer <nils@dinghy.studio>",
  "license": "UNLICENSED",
  "scripts": {
    "start": "sanity start",
    "build": "sanity build"
  },
  "keywords": [
    "sanity"
  ],
  "dependencies": {
    "@sanity/base": "^2.7.1",
    "@sanity/components": "^2.2.6",
    "@sanity/core": "^2.7.1",
    "@sanity/dashboard": "^2.7.0",
    "@sanity/default-layout": "^2.7.1",
    "@sanity/default-login": "^2.7.0",
    "@sanity/desk-tool": "^2.7.1",
    "@sanity/vision": "^2.7.0",
    "prop-types": "^15.7",
    "react": "^17.0",
    "react-dom": "^17.0"
  },
  "devDependencies": {}
}
Mar 26, 2021, 10:40 AM
Not sure what is going on here. This should work. 🤔
Mar 26, 2021, 10:57 AM
I agree!
Mar 26, 2021, 10:57 AM
😄
Mar 26, 2021, 10:57 AM
this is also not my first sanity setup..
Mar 26, 2021, 10:57 AM
Woops. You have a type in your
deskStructure.js
file.
Mar 26, 2021, 10:58 AM
WHAT!
Mar 26, 2021, 10:58 AM
Typo*
Mar 26, 2021, 10:58 AM
Where?
Mar 26, 2021, 10:58 AM
Your
deskStructure.js
file. It's called
deskStucture.js
.
Mar 26, 2021, 10:58 AM
NOOOOOOO
Mar 26, 2021, 10:59 AM
hehe … man
Mar 26, 2021, 11:02 AM
thanks a lot!
Mar 26, 2021, 11:02 AM
case closed
Mar 26, 2021, 11:02 AM
😄 Happy to help.
Mar 26, 2021, 11:03 AM
user P
I got the same error today but because I was renaming by deskStructure file from .js to .ts while sanity.json was still "linking" to the .js file. Maybe it would be worth returning a better error message when the deskStructure file is not found :)
Mar 26, 2021, 11:30 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?

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
How to turn PortableText into plain text in Javascript?Dec 7, 2020
Deploying Next JS on VercelJan 20, 2021
Rendering nested block contentJan 18, 2021
In the tutorial, there is samples of what the API returns as JSON. Is there a way to view these ?Jan 11, 2021
DOMParser is not defined at defaultParseHtmlDec 3, 2020
Next.js and Vercel - Error! No Output Directory named "dist" foundAug 8, 2022
List Arrays - Is it Possible to Fill a List Array Within a Schema Asynchronously?Mar 16, 2021
Custom Document Views - Is it Even Possible to Use the Structure Builder?Apr 21, 2022
TypeError: Cannot Read Properties of Null (Reading 'jsonType')Sep 28, 2022
Error in custom validation rule for schema in Slack threadAug 18, 2023

Related contributions

Turbo Start Sanity
- Template

The battle-tested Sanity template that powers Roboto Studio's websites

Go to Turbo Start Sanity

Schema UI - Next.js Sanity Starter
- Template

A Next.js starter template with Next.js 15, Tailwind CSS, shadcn/ui, and Sanity CMS with Live Editing. Get production-ready React components with matching Sanity schemas and queries. Build dynamic pages faster while keeping full control over customization.

Serge Ovcharenko
Go to Schema UI - Next.js Sanity Starter

The Swaddle
- Made with Sanity

A new brand identity to represent a more mature company, to signify The Swaddle’s evolution from publisher to production house, combined with an easier to navigate platform that can surface multiple content types - drawing readers through The Swaddle’s content offering.

Nightjar
Go to The Swaddle