Troubleshooting installation of @sanity/client dependency in Next.js
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:
- Ignore the warnings - As long as you're not seeing actual errors when running your app, everything should work fine
- Test your application - Run your Next.js app and verify that image handling works correctly
- Don't use
--legacy-peer-depsor--forceunless 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.
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.