
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe error you're encountering (Error: spawn cmd ENOENT) is a Windows-specific issue where the Sanity CLI is trying to automatically open your browser for login but can't find the cmd command. This typically happens due to PATH environment variable issues or permission problems on Windows.
Here are several solutions to get you past this:
When you see the error, the CLI has already generated a login URL. Copy the URL that appears in the error message (the https://api.sanity.io/v1/auth/login/sanity?... part) and paste it directly into your browser. Complete the login there, and the CLI should detect it and continue with the initialization.
If you need to authenticate without the browser flow, you can use an authentication token with environment variables. First, get a token from your Sanity account settings, then use it like this:
SANITY_AUTH_TOKEN=<your-token> sanity initOn Windows Command Prompt:
set SANITY_AUTH_TOKEN=<your-token> sanity init
On Windows PowerShell:
$env:SANITY_AUTH_TOKEN="<your-token>" sanity init
This approach is documented in the Sanity CLI documentation for running commands with authentication.
The ENOENT error means Node.js can't find the cmd executable. Try these approaches:
Run your terminal as Administrator - Right-click your command prompt/PowerShell and select "Run as administrator", then try again
Check your PATH environment variable:
C:\Windows\System32 is in your PATHUse a different terminal:
If you continue having issues, you can use the modern create command:
npm create sanity@latestThis newer approach (npm create sanity@latest) is generally more reliable than sanity init and handles authentication more gracefully across different platforms. You can also specify options directly:
npm create sanity@latest -- --dataset production --template clean --typescriptThe manual browser URL approach is usually the fastest workaround for this specific Windows authentication issue, while switching to npm create sanity@latest gives you a more modern and reliable setup experience overall.
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