
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a Windows-specific issue where Node.js is trying to execute a Unix shell script directly. The error happens because the .bin/sanity file in your node_modules contains bash syntax (basedir=$(dirname...)) that Node.js can't parse on Windows.
This is actually a broader Node.js/npm ecosystem issue on Windows where the wrong executable wrapper gets invoked. When you run yarn sanity dev (or any sanity command), yarn should be using the Windows-compatible .cmd wrapper file, but instead it's trying to execute the Unix shell script, which causes Node.js to choke on the bash syntax.
Potential solutions to try:
Use the .cmd extension explicitly in your package.json scripts:
{
"scripts": {
"dev": "sanity.cmd dev",
"build": "sanity.cmd build"
}
}Run commands with the .cmd extension directly in your terminal:
yarn sanity.cmd devSwitch to npm for this project, as some users have reported this being a yarn-specific path resolution issue on Windows. Delete your node_modules and yarn.lock, then:
npm install
npm run devCheck your Node.js version - Make sure you're on a recent LTS version (Node 20+ is required for Sanity Studio v4 according to the breaking changes documentation). Sometimes path resolution issues in .bin wrappers can be version-specific.
Try running the command through npx as an alternative:
npx sanity devClear and reinstall - Sometimes the .bin wrappers get corrupted during installation:
rm -rf node_modules
rm yarn.lock
yarn installThe fact that you're seeing this with the latest preview version and with yarn specifically (when others report it working with yarn) suggests this might be an edge case in how the CLI binaries are being generated for Windows in that preview build. If none of these solutions work, I'd recommend reporting this on the Sanity GitHub repository with your exact Node.js version, yarn version, and Windows version so the team can investigate the preview build's Windows compatibility.
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