
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI understand you're hitting ERESOLVE peer dependency errors when trying to install packages like styled-components and react-icons. This is a common issue in 2025, especially if you're working with React 19, which was recently released and many popular npm packages haven't fully updated their peer dependency declarations yet.
The error occurs because:
styled-components and react-icons explicitly declare peer dependencies for React 16, 17, or 18--legacy-peer-deps flag (Quickest fix)npm install styled-components --legacy-peer-deps
npm install react-icons --legacy-peer-depsThis tells npm to ignore peer dependency conflicts. The packages will likely work fine despite the warnings, since React 19 maintains good backward compatibility.
--force flagnpm install styled-components --forceThis overrides the peer dependency check. More aggressive than --legacy-peer-deps but works when that doesn't.
.npmrcCreate or edit .npmrc in your project root:
legacy-peer-deps=true
This applies the flag to all future installs automatically.
react-icons has a newer version that supports React 19If you're using Sanity Studio v4, note that it requires Node.js 20+ and React 18+. Make sure there aren't conflicting versions by checking:
npm ls styled-components
npm ls reactIf you see multiple versions, that could be the root cause. Sanity Studio internally uses styled-components, so version conflicts can cause issues.
Start with --legacy-peer-deps for both packages. React 19's backward compatibility is excellent, and these packages will almost certainly work fine. The peer dependency declarations just haven't been updated yet because React 19 is so new.
npm install styled-components react-icons --legacy-peer-depsThen test your app thoroughly. If everything works (which it likely will), you're good to go! If you continue having issues, check your React version with npm ls react to confirm what you're actually running.
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