{"record":{"id":"db65309641f6a6c8","repo":"parcel-bundler/parcel","slug":"unsupported-main-field-field","errorCode":null,"errorMessage":"Unsupported main field \"${field}\"","messagePattern":"Unsupported main field \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/utils/node-resolver-core/src/Wrapper.js","lineNumber":845,"sourceCode":"  for (let field of mainFields) {\n    switch (field) {\n      case 'main':\n        entries |= MAIN;\n        break;\n      case 'module':\n        entries |= MODULE;\n        break;\n      case 'source':\n        entries |= SOURCE;\n        break;\n      case 'browser':\n        entries |= BROWSER;\n        break;\n      case 'types':\n        entries |= TYPES;\n        break;\n      default:\n        throw new Error(`Unsupported main field \"${field}\"`);\n    }\n  }\n\n  return entries;\n}\n","sourceCodeStart":827,"sourceCodeEnd":851,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/utils/node-resolver-core/src/Wrapper.js#L827-L851","documentation":"Thrown by @parcel/node-resolver-core's mainFieldsToEntries helper when a mainFields config entry is anything other than 'main', 'module', 'source', 'browser', or 'types'. The switch maps each known field to a bitmask flag; the default branch rejects unknown fields with a plain Error (no diagnostic wrapping).","triggerScenarios":"User-configured mainFields (resolver option) contains a typo or unsupported value such as 'main.js', 'esnext', 'browser2', 'umd'.","commonSituations":"Copying a webpack/resolve.mainFields list into Parcel's resolver config, custom fields in package.json mistakenly listed, or a typo when migrating from another bundler.","solutions":["Restrict mainFields to the supported set: main, module, source, browser, types.","Remove any custom/typo entry from the mainFields array in your resolver config.","If you need a custom package.json field, handle it via a different resolver hook rather than mainFields."],"exampleFix":"// before\nmainFields: ['browser', 'module', 'main', 'esnext']\n// after\nmainFields: ['browser', 'module', 'main']","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['main','module','source','browser','types']);\nconst bad = (mainFields || []).filter(f => !ALLOWED.has(f));\nif (bad.length) throw new Error('Unsupported mainFields: ' + bad.join(', '));","typeGuard":"const ALLOWED_MAIN_FIELDS = new Set(['main','module','source','browser','types']);\nfunction areValidMainFields(fields) {\n  return fields.every(f => ALLOWED_MAIN_FIELDS.has(f));\n}","tryCatchPattern":null,"preventionTips":["Limit mainFields to the supported set when porting config from other bundlers.","Do not list custom package.json fields in mainFields.","Add a CI schema check on resolver config."],"tags":["resolver","main-fields","config","validation"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}