Using Yarn.lock or Package-lock.json with Sanity Studio
I understand your frustration! Based on the official Sanity CLI documentation, the sanity init command does include a --package-manager flag that lets you specify which package manager to use.
However, I need to be honest: the official documentation doesn't explicitly state whether the CLI automatically detects lock files. The docs only mention that you can specify a package manager manually with the flag.
If the CLI isn't respecting your package-lock.json file automatically, here are your options:
1. Use the explicit flag during initialization:
sanity init --package-manager npm2. Use npm's create command instead:
npm create sanity@latestThis approach uses npm's native project scaffolding, which should respect your npm workflow.
3. For existing projects: If you already have a Sanity project and want to ensure npm is used for all operations:
- Delete any
yarn.lockfile if it exists - Run
npm installto generate/update yourpackage-lock.json - Use npm commands (
npm run dev,npm install, etc.) going forward
The Sanity CLI commands like sanity dev and sanity deploy should work fine regardless of which package manager installed the dependencies.
About your feedback as a paid customer: Your point is valid. Many modern CLI tools (like Create React App, Vite, etc.) do automatically detect lock files, and it would be a nice quality-of-life improvement if Sanity's CLI had more explicit documentation about this behavior—or better automatic detection if it's not already implemented.
If this is a significant pain point for your team, I'd recommend opening a feature request on the Sanity GitHub discussions or reaching out to Sanity support. They're generally responsive to customer feedback, especially from paid plan users.
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.