Error encountered while testing sanity, resolved by deleting node_modules folder.

3 replies
Last updated: Jul 27, 2023
Hey Everyone I run into this error while trying to test sanity
@omar ➜ sanity-test npm create sanity@latest

Need to install the following packages:

create-sanity@3.14.3

Ok to proceed? (y) y

npm WARN cleanup Failed to remove some directories [

npm WARN cleanup   [

npm WARN cleanup     'C:\\Users\\omar\\AppData\\Local\\npm-cache\\_npx\\67a0730928194b24\\node_modules\\@sanity\\cli',

npm WARN cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\omar\AppData\Local\npm-cache\_npx\67a0730928194b24\node_modules\@sanity\cli\src\actions\init-project\templates\nextjs'] {

npm WARN cleanup       errno: -4048,

npm WARN cleanup       code: 'EPERM',

npm WARN cleanup       syscall: 'rmdir',

npm WARN cleanup       path: 'C:\\Users\\omar\\AppData\\Local\\npm-cache\\_npx\\67a0730928194b24\\node_modules\\@sanity\\cli\\src\\actions\\init-project\\templates\\nextjs'

npm WARN cleanup     }

npm WARN cleanup   ]

npm WARN cleanup ]

npm ERR! code 1

npm ERR! path C:\Users\omar\AppData\Local\npm-cache\_npx\67a0730928194b24\node_modules\esbuild

npm ERR! command failed

npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js

npm ERR! node:internal/errors:865

npm ERR!   const err = new Error(message);

npm ERR! Error: Command failed: C:\Program Files\nodejs\node.exe C:\Users\omar\AppData\Local\npm-cache\_npx\67a0730928194b24\node_modules\esbuild\bin\esbuild --version

npm ERR! Node.js v18.17.0
AI Update

Based on the error you're seeing, the main issue is that you're using Node.js v18.17.0, but Sanity Studio v4 requires Node.js version 20 or higher. The error with esbuild failing to install is a symptom of this version incompatibility.

Here's how to fix this:

1. Upgrade to Node.js 20 or higher

You need to upgrade your Node.js installation. The easiest way to do this on Windows is:

  • Download directly from nodejs.org - Get the LTS (Long Term Support) version, which is currently v20 or higher
  • Or use a version manager like nvm-windows to easily switch between Node versions

After installing, verify your version with:

node -v

You should see v20.x.x or higher.

2. Clear your npm cache

Since you're seeing those EPERM errors related to the npm cache, it's a good idea to clear it after upgrading:

npm cache clean --force

3. Try the installation again

Now run the Sanity creation command again:

npm create sanity@latest

Why this happened

As explained in Sanity's blog post about the v4 requirements, Sanity Studio v4 requires Node.js 20+ because Node.js 18 reached end-of-life in April 2024. This change allows Sanity to use modern tooling improvements like Vite 7, which provides faster builds and better performance.

The EPERM (operation not permitted) errors you're seeing with the npm cache and the esbuild installation failure are both consequences of trying to run packages that expect Node.js 20+ features on your current Node.js 18 installation.

This is an issue with settings on your machine. Try looking up the error code for a resolution.
Thanks I'll Look it up!
So I fixed it by deleting the node_modules folder that exists in the error message.Works Just fine right now

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.

Was this answer helpful?