@sanity/client peer dependency conflict with next-sanity-image in Next.js

2 replies
Last updated: Jan 28, 2026
I’m running Next.js and I’ve installed all dependencies except @sanity/client. When I do install it, I get the warnings listed below. I tried running --legacy-peer-deps and using --force, but that doesn’t solve my conflicts. Do I have to install the other dependencies one by one after @sanity/client to see which one conflicts? Not sure how to proceed.
Warnings from terminal:

npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: stripe-ecommerce-app@0.1.0
npm WARN Found: @sanity/client@5.4.2
npm WARN node_modules/@sanity/client
npm WARN peer @sanity/client@“^5.0.0” from next-sanity-image@6.0.0
npm WARN node_modules/next-sanity-image
npm WARN next-sanity-image@“^6.0.0" from the root project
npm WARN 1 more (the root project)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer @sanity/client@“^5.0.0” from next-sanity-image@6.0.0
npm WARN node_modules/next-sanity-image
npm WARN next-sanity-image@“^6.0.0" from the root project
AI Update

Good news - these are just warnings, not errors! Your project should run fine despite these messages.

The issue is that next-sanity-image@6.0.0 specifies it needs @sanity/client@^5.0.0 as a peer dependency, but you've installed @sanity/client@5.4.2. The ^5.0.0 notation means "any version 5.x.x", so version 5.4.2 actually does satisfy that requirement. npm is just being cautious and warning you about the version resolution.

Why you're seeing this:

npm's peer dependency resolver is sometimes overly cautious. The warning appears because npm is detecting a potential version mismatch, but in reality, @sanity/client@5.4.2 is perfectly compatible with next-sanity-image@6.0.0's requirements.

What you should do:

  1. Ignore the warnings - As long as you're not seeing actual errors when running your app, everything should work fine
  2. Test your application - Run your Next.js app and verify that image handling works correctly
  3. Don't use --legacy-peer-deps or --force unless absolutely necessary - these flags can hide real dependency issues

If you want cleaner installs:

You could consider updating to a more recent version of @sanity/client (the latest is now v6+), though be aware this might require updating other Sanity packages in your project. The next-sanity-image package should work with newer client versions too.

Alternative approach:

If you're starting a new project or can refactor, you might want to look at next-sanity which provides official Next.js integration including image handling, and tends to have better maintained peer dependencies.

The bottom line: these warnings are cosmetic. Your setup should work perfectly fine as-is! You don't need to install dependencies one by one - there's no actual conflict here, just npm being overly cautious about version matching.

Show original thread
2 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.

Was this answer helpful?