v3 migration error: sanity-plugin-media using incompatible "part:" imports
The error you're encountering is because you have the Studio v2 version of sanity-plugin-media installed, which uses the deprecated Parts System (part:@sanity/base/* imports). These parts were completely removed in Studio v3.
The good news is that sanity-plugin-media does have a v3-compatible versionβit's the same package name, but you need to ensure you're installing the correct version. Here's how to fix it:
Uninstall the old version:
npm uninstall sanity-plugin-mediaInstall the Studio v3 compatible version:
npm install sanity-plugin-media@studio-v3Alternatively, if the latest version is v3-compatible (which it should be now), you can use:
npm install sanity-plugin-media@latestUpdate your
sanity.config.ts(or.js) file:The plugin configuration syntax has changed for v3. Make sure you're importing and using it correctly:
import { defineConfig } from 'sanity' import { media } from 'sanity-plugin-media' export default defineConfig({ // ... other config plugins: [ media() // ... other plugins ] })Clean install: After updating, delete
node_modulesandpackage-lock.json, then runnpm installfresh.
The key issue is that during migration, npm may have kept the v2 version of the plugin in your dependencies. By explicitly installing the @studio-v3 tag or @latest, you ensure you get the v3-compatible version that doesn't use the old parts system.
Additional note: If you're on an Enterprise plan, you might also want to explore Sanity's built-in Media Library feature, which is an organization-scoped DAM addon with enhanced capabilities like metadata management, versioning, and GROQ queries. But sanity-plugin-media works great for most use cases and is available on all plans.
Show original thread3 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.