
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis error typically happens when you're using the @sanity/orderable-document-list plugin in a Next.js project (or similar framework) that isn't configured to properly transpile the Sanity UI package. The error message about "sourceType: module" indicates that webpack is encountering ES modules but doesn't know how to handle them.
The most common fix is to add the Sanity packages to your Next.js transpilation configuration. In your next.config.js (or next.config.mjs), add the transpilePackages option:
/** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ['@sanity/ui', '@sanity/orderable-document-list']
}
module.exports = nextConfigIf you're using next.config.mjs:
/** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ['@sanity/ui', '@sanity/orderable-document-list']
}
export default nextConfigThis tells Next.js to process these packages through its build pipeline, converting the ES modules into a format that webpack can understand.
A few other things to check:
Make sure you're on a recent version of Next.js - The transpilePackages option was added in Next.js 13.1. If you're on an older version, you might need to upgrade or use the older next-transpile-modules package.
Verify your installation - Sometimes clearing your node_modules and reinstalling can help:
rm -rf node_modules package-lock.json
npm installCheck for conflicting versions - The @sanity/orderable-document-list plugin has peer dependencies on @sanity/ui. Make sure your versions are compatible by checking the plugin's npm page.
After making these changes, restart your development server completely. The error should be resolved and you'll be able to use the orderable-document-list plugin to add drag-and-drop ordering to your documents!
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