{"record":{"id":"141680e01f684a47","repo":"denoland/deno","slug":"err-invalid-arg-value-141680","errorCode":"ERR_INVALID_ARG_VALUE","errorMessage":"The property 'exportNames.${name}' is duplicated. Received ${name}","messagePattern":"The property 'exportNames\\.(.+?)' is duplicated\\. Received (.+?)","errorType":"validation","errorClass":"ERR_INVALID_ARG_VALUE","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/vm.js","lineNumber":853,"sourceCode":"  }\n}\n\nclass SyntheticModule extends Module {\n  constructor(exportNames, evaluateCallback, options = { __proto__: null }) {\n    super();\n    if (\n      !ArrayIsArray(exportNames) ||\n      ArrayPrototypeSome(exportNames, (e) => typeof e !== \"string\")\n    ) {\n      throw new ERR_INVALID_ARG_TYPE(\n        \"exportNames\",\n        \"Array of unique strings\",\n        exportNames,\n      );\n    }\n    ArrayPrototypeForEach(exportNames, (name, i) => {\n      if (ArrayPrototypeIndexOf(exportNames, name, i + 1) !== -1) {\n        throw new ERR_INVALID_ARG_VALUE(\n          `exportNames.${name}`,\n          name,\n          \"is duplicated\",\n        );\n      }\n    });\n    if (typeof evaluateCallback !== \"function\") {\n      throw new ERR_INVALID_ARG_TYPE(\n        \"evaluateCallback\",\n        \"function\",\n        evaluateCallback,\n      );\n    }\n    validateObject(options, \"options\");\n    const {\n      identifier = `vm:module(${defaultModuleIdIndex++})`,\n      context,\n    } = options;","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/vm.js#L835-L871","documentation":"Thrown by the vm.SyntheticModule constructor when exportNames contains the same string more than once (vm.js:850-857). Each export name must be unique because each maps to one slot on the synthetic namespace; duplicates would collide at setExport time, so they are rejected eagerly.","triggerScenarios":"`['default', 'foo', 'default']` from concatenating a default-export list with a named-export list that already includes 'default'; merging export lists from multiple sources without deduping; descriptor arrays generated by spreading two configs; typos duplicated by code generation.","commonSituations":"Building a synthetic facade over a CJS module: `['default', ...Object.keys(module.exports)]` where module.exports already has a `default` key; aggregating re-exports from several sub-modules into one synthetic barrel; codemods or generators that append rather than replace.","solutions":["Dedupe before constructing: `[...new Set(names)]`","When wrapping CJS, exclude an existing default: `['default', ...Object.keys(exports).filter(k => k !== 'default')]`","Add a dev-time assert on uniqueness: `new Set(names).size === names.length`","Fix the generator that produces the list rather than catching the error"],"exampleFix":"// before\nnew vm.SyntheticModule(['default', 'foo', 'default'], cb);\n// after\nnew vm.SyntheticModule([...new Set(['default', 'foo', 'default'])], cb);","handlingStrategy":"validation","validationCode":"if (new Set(exportNames).size !== exportNames.length) {\n  throw new Error(`duplicate export names: ${exportNames}`);\n}\nnew vm.SyntheticModule(exportNames, cb);","typeGuard":null,"tryCatchPattern":"try { new vm.SyntheticModule(names, cb); }\ncatch (e) { if (e.code === 'ERR_INVALID_ARG_VALUE' && /duplicated/.test(e.message)) names = [...new Set(names)]; else throw e; }","preventionTips":["Dedupe merged export lists with [...new Set(names)] before constructing","Exclude 'default' from Object.keys() when you also add it manually","Assert uniqueness in generator tests for synthetic barrels"],"tags":["vm","synthetic-module","duplicate-key","node-compat"],"backgroundTag":"invalid-argument-value","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}