diff --git a/packages/@n8n/ai-utilities/vite.config.ts b/packages/@n8n/ai-utilities/vite.config.ts index 3c8935d2fb1..26dfc1d669e 100644 --- a/packages/@n8n/ai-utilities/vite.config.ts +++ b/packages/@n8n/ai-utilities/vite.config.ts @@ -16,13 +16,12 @@ export default mergeConfig( // Workspace deps CJS-require zod while tests ESM-import it, so // `schema instanceof ZodSchema` in src/converters/tool.ts fails across the // two. Pin the top-level `zod` import to the CJS file so both share one - // module instance. Subpaths like `zod/v4` keep their normal resolution. + // module instance. `require.resolve` follows zod's `require` export condition, + // so it tracks the installed (catalog) version automatically. Subpaths like + // `zod/v4` keep their normal resolution. { find: /^zod$/, - replacement: path.resolve( - __dirname, - '../../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/cjs/index.js', - ), + replacement: require.resolve('zod'), }, ], }, diff --git a/packages/@n8n/instance-ai/vite.config.ts b/packages/@n8n/instance-ai/vite.config.ts index 4531a4f3d69..cba8540843e 100644 --- a/packages/@n8n/instance-ai/vite.config.ts +++ b/packages/@n8n/instance-ai/vite.config.ts @@ -50,13 +50,12 @@ export default mergeConfig( // Workspace deps CJS-require zod while test files ESM-import it, so // `instanceof` checks (e.g. in sanitize-mcp-schemas) fail across the two // module instances. Pin the top-level `zod` import to the CJS file so all - // code paths share one instance. Subpaths like `zod/v4` resolve normally. + // code paths share one instance. `require.resolve` follows zod's `require` + // export condition, so it tracks the installed (catalog) version + // automatically. Subpaths like `zod/v4` resolve normally. { find: /^zod$/, - replacement: path.resolve( - __dirname, - '../../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/cjs/index.js', - ), + replacement: require.resolve('zod'), }, ], }, diff --git a/packages/@n8n/nodes-langchain/vite.config.ts b/packages/@n8n/nodes-langchain/vite.config.ts index 1b7b43aa90e..2317ffae16c 100644 --- a/packages/@n8n/nodes-langchain/vite.config.ts +++ b/packages/@n8n/nodes-langchain/vite.config.ts @@ -12,7 +12,10 @@ export default mergeConfig( alias: { '@utils': path.resolve(__dirname, './utils'), '@nodes-testing': path.resolve(__dirname, '../../core/nodes-testing'), - 'n8n-workflow': path.resolve(__dirname, '../../workflow/dist/cjs/index.js'), + // Pin n8n-workflow to its CJS build so the single module instance is shared + // across CJS-required workspace deps and ESM-imported test code. + // `require.resolve` follows the `require` export condition (the CJS dist). + 'n8n-workflow': require.resolve('n8n-workflow'), }, }, }), diff --git a/packages/core/vite.config.ts b/packages/core/vite.config.ts index e7b3888edfb..3aa65505a45 100644 --- a/packages/core/vite.config.ts +++ b/packages/core/vite.config.ts @@ -16,14 +16,12 @@ export default mergeConfig( // `./dist/cjs/index.js` for `require`) — two separate files with two separate // `ZodType` classes. @n8n/config dist CJS-requires zod, test files ESM-import // it, and `instanceof` fails between them. Pin the top-level `zod` import to the - // CJS file so both code paths share a single module instance. Subpaths like - // `zod/v4` keep their normal resolution. + // CJS file so both code paths share a single module instance. `require.resolve` + // follows zod's `require` export condition, so it tracks the installed (catalog) + // version automatically. Subpaths like `zod/v4` keep their normal resolution. { find: /^zod$/, - replacement: path.resolve( - __dirname, - '../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/cjs/index.js', - ), + replacement: require.resolve('zod'), }, ], },