How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

SyntaxError in Sanity bin script with yarn on latest preview version

5 repliesLast updated: Dec 2, 2025

Heyo everyone, does anyone know why I would be getting this error when I am using yarn with the latest preview version?I have been seeing around that people are getting this with pnpm and having it work with npm / yarn, but for me that's not the case.


E:\Projects\test\node_modules\sanity\node_modules\.bin\sanity:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at Object.compileFunction (node:vm:353:18)
    at wrapSafe (node:internal/modules/cjs/loader:1040:15)
    at Module._compile (node:internal/modules/cjs/loader:1076:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:834:12)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (E:\Projects\test\node_modules\sanity\bin\sanity:10:3)
    at Module._compile (node:internal/modules/cjs/loader:1112:14)
AI Update

This 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:

The 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.

Show original thread
5 replies

Was this answer helpful?

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.

Related contributions