Error installing Transifex Plugin due to duplicate definition of part

5 replies
Last updated: Aug 19, 2022
Plugins “@sanity/production-preview” and “@sanity/production-preview” both define part “part:@sanity/transitional/production-preview/resolve-production-url”
Trying to install Transifex Plugin (
https://www.sanity.io/plugins/sanity-plugin-transifex ) when
exec populateTransifexSecrets.js --with-user-token
fails with
 $ sanity exec populateTransifexSecrets.js --with-user-token
/Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/resolver/lib/resolver.js:170
    throw new Error("".concat("Plugins ".concat(existing, " and ").concat(current, " both define part \"").concat(part.name, "\"") + ' - did you mean to use "implements"?\n' + 'See ').concat((0, _generateHelpUrl.generateHelpUrl)('part-declare-vs-implement')));
    ^

Error: Plugins "@sanity/production-preview" (/Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/production-preview) and "@sanity/production-preview" (/Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/production-preview) both define part "part:@sanity/transitional/production-preview/resolve-production-url" - did you mean to use "implements"?
See <https://docs.sanity.io/help/part-declare-vs-implement>
    at assignDefinitionForAbstractPart (/Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/resolver/lib/resolver.js:170:11)
    at /Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/resolver/lib/resolver.js:137:9
    at Array.forEach (<anonymous>)
    at /Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/resolver/lib/resolver.js:133:11
    at Array.forEach (<anonymous>)
    at mergeResult (/Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/resolver/lib/resolver.js:130:15)
    at resolveParts (/Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/resolver/lib/resolver.js:50:12)
    at registerLoader (/Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/plugin-loader/loader.js:35:7)
    at Object.<anonymous> (/Users/kristoffer.nordkvist/src/web-client-cms/web-client-cms/node_modules/@sanity/core/lib/actions/exec/pluginLoader.js:6:1)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
AI Update

This error occurs because your sanity.json configuration has incorrectly combined two separate parts into one entry. The error message is confusing (showing the same plugin twice) because the parts system is detecting a conflict in how you've declared the schema part.

The Problem

In your sanity.json, you likely have something like:

"parts": [
  {
    "name": "part:@sanity/base/schema",
    "implements": "part:@sanity/production-preview/resolve-production-url",
    "path": "./resolve-production-url.js"
  }
]

This is combining your schema declaration with the production preview implementation, which causes the resolver to fail. The name property declares a part, while implements provides an implementation for a different part - they shouldn't be in the same object.

The Solution

As explained in this answer about fixing parts in sanity.json, you need to separate these into distinct part entries. Your sanity.json should look like this:

"parts": [
  {
    "name": "part:@sanity/base/schema",
    "path": "./schemas/schema.js"
  },
  {
    "implements": "part:@sanity/production-preview/resolve-production-url",
    "path": "./resolve-production-url.js"
  }
]

Make sure the path to your schema file is correct (it should point to your actual schema file, like ./schemas/schema.js or wherever you've defined your schema).

If you also have a desk structure, add it as a separate part:

"parts": [
  {
    "name": "part:@sanity/base/schema",
    "path": "./schemas/schema.js"
  },
  {
    "name": "part:@sanity/desk-tool/structure",
    "path": "./deskStructure.js"
  },
  {
    "implements": "part:@sanity/production-preview/resolve-production-url",
    "path": "./resolve-production-url.js"
  }
]

Important Context

This is a Sanity Studio v2 issue - the "parts" system was completely removed in Studio v3. If you're starting a new project or can upgrade, I'd strongly recommend moving to Studio v3, which has a much simpler plugin system and avoids these types of configuration conflicts entirely.

Additionally, the sanity-plugin-transifex plugin appears to be designed for Studio v2. Before investing time in fixing this, check if the plugin has been updated for Studio v3 compatibility, or if there's an alternative translation solution that works with the current version of Sanity.

Could you nuke your node modules and reinstall them fresh please?
It fails the same way
Can you share your sanity.json?
Yep! Thanks for looking into this 🙂
Solved!
@sanity/production-preview
was defined twice. Both in plugins but also in env.development.plugins in sanity.json.
Thank you for your time
🙏

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?