Unlock seamless workflows and faster delivery with our latest releases – get the details

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?