
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI found the exact issue you're experiencing! This is a common problem when setting up the production preview feature in Sanity Studio v2 (the older version using sanity.json).
The error schema.getTypeNames is not a function happens because your sanity.json file has incorrectly combined two separate "parts" into one. Looking at your configuration:
"parts": [
{
"name": "part:@sanity/base/schema",
"implements": "part:@sanity/production-preview/resolve-production-url",
"path": "./resolve-production-url.js"
}
]The problem is that you're telling Sanity that your schema file is located at ./resolve-production-url.js, which is actually your production URL resolver. This causes the schema system to fail because it can't find the proper schema definition.
You need to separate these into two distinct parts in your sanity.json:
"parts": [
{
"name": "part:@sanity/base/schema",
"path": "./schemas/schema.js"
},
{
"name": "part:@sanity/desk-tool/structure",
"path": "./deskStructure.js"
},
{
"implements": "part:@sanity/production-preview/resolve-production-url",
"path": "./resolve-production-url.js"
}
]Key points:
createSchema export)"implements" instead of "name"Make sure the path in the first entry ("./schemas/schema.js" or similar) matches where your actual schema file is located - the one with the createSchema function you shared earlier.
After making this change, restart your Studio dev server and the error should be resolved!
Note: If you're starting a new project today, I'd recommend using Sanity Studio v3, which has moved away from the sanity.json parts system to a more straightforward configuration approach using sanity.config.ts.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store