prettier/prettier · error · Error
printer.embed has too many parameters. The API changed in Pr
Error message
printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed
What it means
In Prettier v3 the `embed` API changed: it now takes `(path, options)` and returns a function, instead of v2's `(path, print, textToDoc, options)`. The multiparser checks `embed.length > 2` (src/main/multiparser.js:26) and throws immediately so outdated plugins fail fast with an actionable migration message.
Source
Thrown at src/main/multiparser.js:26
/** @type {AstPath} */ path,
genericPrint,
options,
printAstToDoc,
embeds,
) {
if (options.embeddedLanguageFormatting !== "auto") {
return;
}
const { printer } = options;
const { embed } = printer;
if (!embed) {
return;
}
if (embed.length > 2) {
throw new Error(
"printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed",
);
}
const { hasPrettierIgnore } = printer;
const { getVisitorKeys } = embed;
const embedCallResults = [];
recurse();
const originalPathStack = path.stack;
for (const { print, node, pathStack } of embedCallResults) {
try {
path.stack = pathStack;
const doc = await print(textToDocForEmbed, genericPrint, path, options);
View on GitHub (pinned to 315f281982)
Solutions
- Upgrade the plugin to a Prettier v3-compatible release.
- If you own the plugin, rewrite embed to the v3 signature: `embed(path, options)` returning an async `(textToDoc) => doc` function.
- Temporarily remove the incompatible plugin until it ships a v3 build.
- Verify the plugin's peerDependencies declare prettier 3 support.
Example fix
// before (v2 embed)
function embed(path, print, textToDoc, options) {
// ...
}
// after (v3 embed)
function embed(path, options) {
return async (textToDoc) => {
// ...
};
} Defensive patterns
Strategy: validation
Validate before calling
// Reject plugins with an outdated embed signature before registering them
function isV3CompatiblePlugin(plugin) {
for (const printer of Object.values(plugin?.printers ?? {})) {
const embed = printer?.embed;
if (typeof embed === "function" && embed.length > 2) return false;
}
return true;
} Prevention
- After upgrading Prettier major versions, audit every plugin for v3 compatibility.
- Pin plugins that declare the correct prettier peer range.
- Gate plugin registration on an embed.length <= 2 check.
When it happens
Trigger: Loading a Prettier v2 plugin whose printer.embed declares 3 or 4 parameters into a Prettier v3 host. Common when upgrading an app to Prettier 3 while a community plugin has not published a v3-compatible release.
Common situations: Major-version Prettier upgrade with stale plugins; plugin peerDependencies still pinned to prettier 2.
Related errors
- Unexpected JSX node type: ${node.type}.
- Unexpected specifier node type: ${node.type}.
- Unexpected TypeScript node type: ${node.type}.
- Couldn't resolve parser "${parserName}".
- Couldn't find plugin for AST format "${astFormat}".
AI-assisted analysis of prettier/prettier@315f281982 (2026-08-03).
Data as JSON: /data/errors/5c7f7cd026c4bf45.json.
Report an issue: GitHub.