Module parse error with @sanity/orderable-document-list plugin import

15 replies
Last updated: Nov 29, 2025
Hi! I am new to Sanity and adding some documentation to my site. I’d like to add the
@sanity/orderable-document-list
plugin, but get this error:
./node_modules/@sanity/orderable-document-list/node_modules/@sanity/ui/dist/index.esm.js
Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (61:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See <https://webpack.js.org/concepts#loaders>
Any help or insight appreciated! Thank you!
AI Update

This 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 = nextConfig

If you're using next.config.mjs:

/** @type {import('next').NextConfig} */
const nextConfig = {
  transpilePackages: ['@sanity/ui', '@sanity/orderable-document-list']
}

export default nextConfig

This 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:

  1. 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.

  2. Verify your installation - Sometimes clearing your node_modules and reinstalling can help:

    rm -rf node_modules package-lock.json
    npm install
  3. Check 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!

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