EPERM error when installing Sanity with npm --legacy-peer-deps
The EPERM error you're encountering is a permissions issue on Windows when trying to install Sanity packages. This is actually documented in Sanity's official CLI errors documentation, and there are several solutions you can try:
Quick Fixes to Try
1. Run as Administrator The most straightforward solution is to run your terminal/command prompt as an Administrator. Right-click on your terminal application and select "Run as Administrator", then try the installation again.
2. Clear npm cache Sometimes cached data can cause permission issues:
npm cache clean --force
npm cache verify3. Reinstall Node.js If the above doesn't work, try completely uninstalling and reinstalling Node.js. This often resolves underlying permission configuration issues.
4. Use a package manager alternative
If you're still stuck, try using pnpm or yarn instead of npm, as they handle permissions differently:
# Using pnpm
pnpm install @sanity/vision@3 sanity@3 @sanity/image-url@1 styled-components@6
# Or using yarn
yarn add @sanity/vision@3 sanity@3 @sanity/image-url@1 styled-components@6Windows-Specific Issue
The --legacy-peer-deps flag in your command suggests there might also be dependency conflicts. On Windows, EPERM errors are commonly related to the $PATH environment variable or file system permissions. Make sure your user account has write permissions to the npm directories.
If none of these solutions work, the Sanity community Slack is very responsive and can help troubleshoot Windows-specific installation issues. The feedback form on the docs page is also monitored by the team.
Show original thread2 replies
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.