
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGood 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 installThis 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.jsonpnpm 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:
sanity.config.ts (or .js) file with your project IDsanity.cli.ts (or .js) fileEverything 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! 🎉
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