Import error: 'retry' not exported from 'get-it/middleware' in Sanity client

12 replies
Last updated: Nov 29, 2025
Hi everyone, I've been troubleshooting this dev error for a while so finally asking the larger community. Error shows up on
npm run dev
command:

Import trace for requested module:
./node_modules/<@UFY5PJF3M>/client/dist/index.browser.js
./sanity/sanity.client.ts
./sanity/sanity.query.ts
./app/(site)/projects/[project]/page.tsx
 ⨯ ./node_modules/<@UFY5PJF3M>/client/dist/index.browser.js
Attempted import error: 'retry' is not exported from 'get-it/middleware' (imported as 'retry').
And then the attached image is what it looks like.

I'm not too sure where to start on this kind of thing so any advice would be super duper helpful. Happy to provide any other info that's needed. Thanks in advance!
AI Update

This is a common dependency compatibility issue between @sanity/client and its underlying get-it package when using older versions of Next.js. Based on a resolved case in the Sanity community, the solution involves upgrading your Next.js version.

What's Causing This Error

The error 'retry' is not exported from 'get-it/middleware' happens because older Next.js versions (particularly Next.js 13) have fallen out of compatibility with current Sanity packages. The get-it package that powers @sanity/client has evolved its module exports in ways that older bundlers don't handle correctly.

The Solution: Upgrade to Next.js 14+

Here's the step-by-step fix:

1. Clean Your Project

Remove existing dependencies to start fresh:

rm -rf node_modules package-lock.json

2. Update package.json

Upgrade these key packages to their latest versions:

{
  "dependencies": {
    "next": "latest",
    "next-sanity": "latest",
    "@sanity/client": "latest"
  }
}

3. Reinstall Dependencies

If you have peer dependency conflicts (common with styled-components):

npm install --legacy-peer-deps

4. Verify Everything Works

Test both development and production builds:

npm run dev
npm run build

Quick Workarounds (Temporary)

If you can't upgrade immediately, try these:

Force Vite to re-bundle:

npm run dev -- --force

Or clear cache completely:

rm -rf node_modules
npm install --legacy-peer-deps

Additional Troubleshooting

  • If you see Invalid Version: 6.1 during npm install, check for malformed version strings in your dependencies
  • Ensure you're using Node.js 18+ (required for modern Next.js and Sanity versions)
  • The error occurs in index.browser.js because it's happening during browser bundle compilation
  • If using npm-force-resolutions, remove it from your package.json—modern npm versions handle resolutions differently

The upgrade to Next.js 14 or later is the most reliable long-term solution. Sanity's current packages are built and tested against modern Next.js versions, ensuring proper bundling and module resolution.

Show original thread
12 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?