Sanity CLI dataset and CORS commands not found in Studio v3
Good news - those commands still exist! The error message is actually telling you exactly what's happening: you need to run these commands from within a Sanity project directory, not just anywhere on your system.
The Context Issue
In Sanity CLI v3, many commands like dataset and cors require you to be inside a Sanity project folder (where @sanity/core is installed as a dependency). This is different from some global CLI operations that can run anywhere.
Here's how to fix this:
- Navigate to your Sanity project directory (where your
sanity.config.tsorsanity.config.jsfile lives) - Then run the commands:
cd /path/to/your-sanity-project
sanity dataset list
sanity cors listAvailable Dataset & CORS Commands
Once you're in the correct directory, these commands should work:
Dataset commands:
sanity dataset list- List all datasets in your projectsanity dataset create <name>- Create a new datasetsanity dataset export- Export dataset contentsanity dataset import- Import data into a dataset
CORS commands:
sanity cors list- List CORS originssanity cors add <origin>- Add a CORS originsanity cors delete <id>- Remove a CORS origin
CLI Configuration
Make sure your project has a CLI configuration file (sanity.cli.js or sanity.cli.ts) in the project root with your project ID:
import { defineCliConfig } from "sanity/cli";
export default defineCliConfig({
api: {
projectId: 'your-project-id',
dataset: 'production'
}
});You can find more details in the official CLI documentation.
If you're trying to manage multiple projects, you'll need to cd into each project's directory before running these context-dependent commands, or use the --project flag where supported to specify which project you're working with.
Show original thread13 replies
Sanity – Build the way you think, not the way your CMS thinks
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.