See how we built our intranet. Live + Q&A, June 30

Sanity CLI: Respect yarn.lock or package-lock.json for package manager detection

3 repliesLast updated: Dec 1, 2025

Would it be possible to have the Sanity CLI respect the presence of either
yarn.lock
or
package-lock.json
and when a single lock file is present… Use that package manager? We use NPM basically everywhere and I’d love to not need to use
yarn
strictly when dealing with a Sanity Studio project.
It is a small thing, but as a paid product it would be a nice touch if this wasn’t an area we didn’t need to adjust our normal work flow.
AI Update

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 npm

2. Use npm's create command instead:

npm create sanity@latest

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

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.

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