diff --git a/lib/getPostcssResult.js b/lib/getPostcssResult.js index 143136bb5e..4b00c5aa87 100644 --- a/lib/getPostcssResult.js +++ b/lib/getPostcssResult.js @@ -94,10 +94,16 @@ function getCustomSyntax(customSyntax) { try { resolved = require(customSyntax); } catch (error) { - // @ts-expect-error -- TS2571: Object is of type 'unknown'. - if (error && typeof error === 'object' && error.code === 'MODULE_NOT_FOUND') { + if ( + error && + typeof error === 'object' && + // @ts-expect-error -- TS2571: Object is of type 'unknown'. + error.code === 'MODULE_NOT_FOUND' && + // @ts-expect-error -- TS2571: Object is of type 'unknown'. + error.message.includes(customSyntax) + ) { throw new Error( - `Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.`, + `Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.\n\nCaused by: ${error}`, ); }