How to delete and reinstall Sanity with session and admin errors

7 replies
Last updated: Jan 27, 2026
How do I delete Sanity? I will reinstall it again right away, as I think it'll be much easier with the issues I am having. However, it's saying either, "A valid session is required at this endpoint" or "Cannot delete user while being the last administrator of a project".  The error I am getting from a project I was getting was" Error: Command "start" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "@sanity/core"
is installed as a dependency.
    at _.runCommand (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:3608:1340)
    at t.exports (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1980:2422)
AI Update

Based on your error message, it looks like you're dealing with a few separate issues that don't actually require deleting your Sanity account or completely uninstalling everything. Let me break down what's happening and how to fix it:

Understanding the Main Error

The error Command "start" is not available outside of a Sanity project context means you're trying to run sanity start from a directory that isn't a Sanity project. The Sanity CLI commands (like sanity start or sanity dev) need to be run from inside a Sanity project folder where @sanity/core is installed as a dependency.

You Don't Need to Delete Your Account

The errors about "Cannot delete user while being the last administrator of a project" and "A valid session is required" are appearing because you're trying to delete your account, but:

  1. You can't delete your account if you're the only admin on a project
  2. Deleting your account won't fix the CLI issue anyway

Good news: You don't need to delete your account or uninstall Sanity globally to fix this!

The Solution

Based on the discussion you found, here's what actually works:

1. Make sure you're in the right directory

The sanity start command only works when you're inside your Sanity project folder. Use cd to navigate to your project directory first:

cd path/to/your/sanity-project

2. If you want a fresh start with a new project

Instead of deleting your account, just create a new Sanity project using the modern approach:

npm create sanity@latest

This will guide you through creating a new project with an interactive setup. When you run this command, it will:

  • Let you log in (or create an account)
  • Ask you to create or select a project
  • Set up a dataset
  • Choose a template
  • Install dependencies

Then you can start your studio with:

npm run dev

Or if you're using the older CLI pattern:

sanity dev

3. If you have old project folders cluttering your computer

You can safely delete old project folders from your file system without affecting your Sanity account or other projects. These are just local files. Search for folders containing sanity.config files and delete the ones you don't need.

4. About the CLI versions

If you have the global CLI installed and want to ensure you're using the latest version:

npm install -g @sanity/cli@latest

Or you can use npx to always run the latest version without a global install:

npx sanity@latest init

Current Best Practice (Studio v3)

The modern way to create a Sanity project is:

npm create sanity@latest

This is cleaner than the older sanity init approach and will set everything up correctly from the start.

Your existing projects in your Sanity account will remain untouched - you're just creating new local project folders on your computer that connect to them.

Show original thread
7 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.

Was this answer helpful?