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

Cloning Sanity project: Cannot find module 'sanity' with pnpm

3 repliesLast updated: Nov 29, 2025

hey sanity peeps! I'm trying to clone an existing project onto a new computer. My other one is having keyboard issues. I decided to try pnpm, but simply cloning the repo and running pnpm (after installing pnpm globally of course) doesn't seem to quite work. I'm getting some red squigglies with the error
Cannot find module 'sanity' or its corresponding type declarations
. Anyone have advice on how to transition from npm to pnpm? And do I have to do anything special as far as sanity setup when cloning an existing repo of mine or should everything be ready to go since I have a cli and config file already defined?
AI Update

Good news - this is usually a simple fix! The "Cannot find module 'sanity'" error you're seeing is typically just TypeScript/your editor being confused before the dependencies are fully installed.

Here's what you need to do when cloning your existing Sanity project and switching to pnpm:

1. Install dependencies with pnpm:

pnpm install

This should install all your dependencies including the sanity package. Since you already have a package.json in your cloned repo, pnpm will read it and install everything.

2. Restart your TypeScript server:

Those red squigglies are often just your editor's TypeScript server not recognizing the newly installed modules. In VS Code:

This should clear up the error immediately.

3. Clean up old lock files (optional but recommended):

If you're transitioning from npm to pnpm, you might want to remove the old lock file to avoid confusion:

rm package-lock.json

pnpm will create its own pnpm-lock.yaml file.

About cloning existing Sanity projects:

You don't need to do any special Sanity setup when cloning your own repo! Since you already have:

Everything should work once dependencies are installed. The Sanity CLI and configuration are project-specific and already in your repo. Just make sure you're authenticated with the CLI (sanity login) if you need to deploy or manage datasets.

One thing to watch out for:

If you happen to have multiple versions of the sanity package installed (rare, but can happen with monorepos or certain dependency configurations), you might see context errors. But in your case with a fresh clone, this shouldn't be an issue.

TL;DR: Run pnpm install, restart your TypeScript server, and you should be good to go! 🎉

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