DEV Community

Nzoputachi Emmanuel
Nzoputachi Emmanuel

Posted on

How to Fix Sanity Studio Module Error on Windows

The Problem

When starting Sanity Studio v4.20.0 on Windows, the development server shows this error:

Error: Unable to resolve `sanity` module root
Enter fullscreen mode Exit fullscreen mode

This happens even after clean install with all dependencies installed properly.

Why This Happens

Sanity version 4.20.0 has circular dependency problem that affects specifically Windows. This is because Windows handles the module paths different from Unix systems. The issue is documented in Sanity GitHub and only Windows users are affected.

How to Fix

Step 1: Downgrade Version

Most reliable solution is downgrading to Sanity v4.18.0 which does not have this problem.

Change the package.json like this:

{
  "dependencies": {
    "sanity": "4.18.0",
    "@sanity/vision": "4.18.0"
  }
}
Enter fullscreen mode Exit fullscreen mode

Important: Remove the caret (^) symbol to pin exact version and prevent automatic updates.

Step 2: Clean Install

Remove existing dependencies and lock files:

# PowerShell or Command Prompt
rmdir /s /q node_modules
del package-lock.json

# Git Bash
rm -rf node_modules package-lock.json
Enter fullscreen mode Exit fullscreen mode

Then reinstall dependencies:

npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

Top comments (0)