Module not found: Can't resolve 'part:@sanity/base/document-actions/resolver

8 replies
Last updated: Aug 17, 2022
Hi πŸ‘‹ I'm trying to follow this tutorial, but are getting an error in
/node_modules/@sanity/desk-tool/lib/panes/document/DocumentPaneProvider.js
when running
sanity start
. The error is
Module not found: Error: Can't resolve 'part:@sanity/base/document-actions/resolver'
in
node_modules/@sanity/desk-tool/lib/panes/document
. Any help would be appreciated πŸ™
AI Update

This error indicates you're running into a Studio v2 vs v3 compatibility issue. The error Can't resolve 'part:@sanity/base/document-actions/resolver' is happening because you're trying to use a tutorial or code written for Sanity Studio v2, but your project dependencies are pulling in Studio v3 packages (or vice versa).

The part: syntax was part of the old Parts System in Studio v2, which was completely removed in Studio v3. This is why the module can't be resolved - it literally doesn't exist in v3.

Here's how to fix it:

Option 1: Upgrade to Studio v3 (Recommended)

If the tutorial is outdated, you should migrate to Studio v3. The modern equivalent would be:

  1. Make sure you're on Studio v3 by checking your package.json - you should have "sanity": "^3.x.x" (not v2)

  2. In Studio v3, the desk tool is imported differently:

import {deskTool} from 'sanity/desk'
  1. Document actions in v3 are configured in your sanity.config.ts/js file:
import {defineConfig} from 'sanity'
import {deskTool} from 'sanity/desk'

export default defineConfig({
  // ... other config
  plugins: [
    deskTool({
      // document actions configuration here
    })
  ]
})

Check out the official v2 to v3 migration guide for complete migration steps.

Option 2: Use Studio v2 (Not recommended - support ended Dec 2023)

If you absolutely need to follow that specific v2 tutorial:

  1. Downgrade to Studio v2 in your package.json: "sanity": "^2.x.x"
  2. Run npm install or yarn install

However, Studio v2 support ended in December 2023, so this isn't advisable for production projects.

Quick check:

Run npm list sanity to see which version you actually have installed. If it's v3 and the tutorial is v2, that's your mismatch. Look for an updated v3 version of the tutorial, or follow the migration guide to convert the v2 code patterns to v3.

Show original thread
8 replies
Hey
user T
! Can you share your
sanity.json
and your
resolveDocumentActions.js
?
sanity.json
:

{
  "root": true,
  "project": {
    "name": "Prescription"
  },
  "api": {
    "projectId": "******",
    "dataset": "production"
  },
  "plugins": [
    "@sanity/base",
    "@sanity/components",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/desk-tool",
    "@sanity/dashboard",
    "order-documents",
    "scheduled-publishing"
  ],
  "env": {
    "development": {
      "plugins": ["@sanity/vision"]
    }
  },
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema"
    },
    {
      "name": "part:@sanity/desk-tool/structure",
      "path": "src/deskStructure.js"
    },
    {
      "implements": "part:@sanity/base/document-actions/resolver",
      "path": "resolveDocumentActions.js"
    }
  ]
}
resolveDocumentActions.js
:

// resolveDocumentActions.js

// import the default document actions
import defaultResolve from 'part:@sanity/base/document-actions'

import {HelloWorldAction} from './HelloWorldAction'

export default function resolveDocumentActions(props) {
  return [...defaultResolve(props), HelloWorldAction]
}
user M
☝️ 😊
Any thoughts
user M
? 😊
Hey
user T
! Patience is key around here. If I'm not answering, it's likely that it's the middle of the night for me, since I'm in PST. I promise I'm never purposely ignoring you!
Can you try deleting node_modules and reinstalling?
okay, sorry 😊 I have tried deleting node modules and reinstalling it with
sanity install
, also I tried to reinstall the relevant packages again
Figured it out! I had chosen a wrong path in sanity.json for the resolver file

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?