{"record":{"id":"83734cece35e8266","repo":"parcel-bundler/parcel","slug":"target-target-name-is-configured-to-overwrite","errorCode":null,"errorMessage":"Target \"${target.name}\" is configured to overwrite entry \"${relativeEntry}\".","messagePattern":"Target \"(.+?)\" is configured to overwrite entry \"(.+?)\"\\.","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/requests/TargetRequest.js","lineNumber":1521,"sourceCode":"        let inputLoc = input.loc;\n        if (inputLoc) {\n          let highlight = convertSourceLocationToHighlight(\n            inputLoc,\n            'Entry defined here',\n          );\n\n          if (inputLoc.filePath === loc.filePath) {\n            codeFrames[0].codeHighlights.push(highlight);\n          } else {\n            codeFrames.push({\n              filePath: fromProjectPath(options.projectRoot, inputLoc.filePath),\n              codeHighlights: [highlight],\n            });\n          }\n        }\n      }\n\n      throw new ThrowableDiagnostic({\n        diagnostic: {\n          origin: '@parcel/core',\n          message: `Target \"${target.name}\" is configured to overwrite entry \"${relativeEntry}\".`,\n          codeFrames,\n          hints: [\n            (COMMON_TARGETS[target.name]\n              ? `The \"${target.name}\" field is an _output_ file path so that your build can be consumed by other tools. `\n              : '') +\n              `Change the \"${target.name}\" field to point to an output file rather than your source code.`,\n          ],\n          documentationURL: 'https://parceljs.org/features/targets/',\n        },\n      });\n    }\n  }\n}\n\nasync function debugResolvedTargets(input, targets, targetInfo, options) {","sourceCodeStart":1503,"sourceCodeEnd":1539,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/requests/TargetRequest.js#L1503-L1539","documentation":"Each target's output destination must not equal a source entry file path. If a target's distPath resolves to the same file as an input entry, the build would overwrite the source. TargetRequest throws with the relative entry path and a hint clarifying that target fields like `main`/`module` are OUTPUT paths. For common targets the hint reminds the user these are output fields.","triggerScenarios":"Pointing a target output field (e.g. `main`, `module`, or a custom target) at the same path as a source/entry file (e.g. `\"main\": \"src/index.js\"` while `src/index.js` is the entry).","commonSituations":"Confusing input `source` and output `main`/`module` fields; pointing `main` at a src file by mistake; refactoring that moved entry files into a location equal to an output path.","solutions":["Change the target field to point at an output location (e.g. `dist/index.js`), not the source.","Move the entry file or output directory so they do not collide.","Set an explicit `source` field distinct from the target output path."],"exampleFix":"// before (package.json)\n{\n  \"source\": \"src/index.js\",\n  \"main\": \"src/index.js\"\n}\n\n// after\n{\n  \"source\": \"src/index.js\",\n  \"main\": \"dist/index.js\"\n}","handlingStrategy":"validation","validationCode":"import path from 'path';\nfunction assertNoEntryOverlap(pkg) {\n  const entries = [pkg.source, ...(pkg.entries || [])].filter(Boolean);\n  const outs = ['main','module','browser','types'].map(f => pkg[f]).filter(Boolean);\n  for (const o of outs) {\n    if (entries.some(e => path.resolve(e) === path.resolve(o))) {\n      throw new Error(`Target output ${o} collides with a source entry.`);\n    }\n  }\n}","typeGuard":"function outputDoesNotOverlapEntries(outputPath, entries) {\n  return !entries.some(e => path.resolve(e) === path.resolve(outputPath));\n}","tryCatchPattern":"try { await parcel.run(); } catch (e) {\n  if (/configured to overwrite entry/.test(e.message)) {\n    console.error('Target output path must differ from source entry paths.');\n  } else throw e;\n}","preventionTips":["Keep source files in `src/` and outputs in `dist/`.","Never set `main`/`module` to a path under your source tree.","Set an explicit `source` field distinct from output fields."],"tags":["parcel","targets","entry-collision","output-path","config"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}