Troubleshooting schema extraction error in Sanity CLI version 3.45.0

6 replies
Last updated: Jun 11, 2024
Hi all. I’m trying to extract my schema to json. I’m running the extract command but am getting the following error

$ sanity schema extract

sanity schema extractError: "extract" is not a subcommand of "sanity schema".  See "sanity --help"
    at CommandRunner.resolveSubcommand (~/.nvm/versions/node/v18.20.2/lib/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:71778:13)
    at CommandRunner.resolveCommand (~/.nvm/versions/node/v18.20.2/lib/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:71754:31)
    at CommandRunner.runCommand (~/.nvm/versions/node/v18.20.2/lib/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:71722:116)
    at Object.runCli (~/.nvm/versions/node/v18.20.2/lib/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:72111:38)
I’m running on version
3.45.0
on node 18.20.2 but I also get the same error on node 20*

$ sanity help schema

usage: sanity schema [--default] [-v|--version] [-d|--debug] [-h|--help] <command> [<args>]

Commands:
   validate  Validates all schema types specified in a workspace.

See 'sanity help schema <command>' for specific information on a subcommand.
Jun 11, 2024, 2:23 PM
Is
3.45.0
the version of the Studio or the CLI that you’re running?
Jun 11, 2024, 4:00 PM
sorry, the cli
Jun 11, 2024, 4:01 PM
Hmm, it looks like it’s present for me on that version of the CLI. What’s your output from
sanity versions
? If you have the sanity package installed globally, what does
npm list -g
output for your version? Do they match?
Jun 11, 2024, 4:49 PM
$ sanity versions

@sanity/cli (global)                   3.45.0 (up to date)
@sanity/document-internationalization   2.0.3 (latest: 3.0.0)
@sanity/icons                          2.10.1 (latest: 3.2.0)
@sanity/image-url                       1.0.2 (up to date)
@sanity/language-filter                 3.2.2 (latest: 4.0.2)
@sanity/pkg-utils                       3.3.8 (latest: 6.9.3)
@sanity/plugin-kit                     3.1.10 (latest: 4.0.17)
@sanity/types                          3.12.0 (latest: 3.45.0)
@sanity/ui                              1.5.0 (latest: 2.3.2)
@sanity/vision                         3.28.0 (latest: 3.45.0)
sanity                                 3.28.0 (latest: 3.45.0)
Ahh so does the local package need to also be >3.35.0?


$ npm list -g               
/Users/simonlegg/.nvm/versions/node/v18.20.2/lib
├── @sanity/cli@3.45.0
...
Jun 11, 2024, 4:50 PM
Ok, the issue was that the
package.json
had
"sanity": "^3.14"
and I guess not having the trailing patch number meant that yarn never grabbed minor version upgrades (odd).
Seems to work now. Although as feedback, it seems weird from a user POV that I guess the cli defers internally to a locally installed version?

Either way, thank you for prompting the fix! Much appreciated
:rubberduck:
Jun 11, 2024, 5:04 PM
Glad you got it sorted out!
Jun 11, 2024, 5:29 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?