{"record":{"id":"db1a172ed8bf54d4","repo":"parcel-bundler/parcel","slug":"cannot-require-resolved-in-the-browser","errorCode":null,"errorMessage":"Cannot require '${resolved}' in the browser","messagePattern":"Cannot require '(.+?)' in the browser","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/repl/src/parcel/BrowserPackageManager.js","lineNumber":161,"sourceCode":"  }\n\n  async require(\n    name: DependencySpecifier,\n    from: FilePath,\n    opts: ?{|\n      range?: ?SemverRange,\n      shouldAutoInstall?: boolean,\n      saveDev?: boolean,\n    |},\n  ): Promise<any> {\n    let {resolved} = await this.resolve(name, from, opts);\n\n    // $FlowFixMe\n    if (resolved in BUILTINS) {\n      return BUILTINS[resolved];\n    }\n\n    throw new Error(`Cannot require '${resolved}' in the browser`);\n  }\n\n  async resolve(\n    name: DependencySpecifier,\n    from: FilePath,\n    // eslint-disable-next-line no-unused-vars\n    options?: ?{|\n      range?: ?SemverRange,\n      shouldAutoInstall?: boolean,\n      saveDev?: boolean,\n    |},\n  ): Promise<ResolveResult> {\n    if (name.startsWith('@parcel/') && name !== '@parcel/watcher') {\n      return Promise.resolve({\n        resolved: name,\n        pkg: {\n          name: name,\n          version: '2.0.0',","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/dev/repl/src/parcel/BrowserPackageManager.js#L143-L179","documentation":"Thrown by `BrowserPackageManager.require` in the in-browser Parcel REPL when a resolved module is not in the `BUILTINS` map. The REPL only has the parcel core plugins bundled in; any other package can be resolved by path but cannot actually be `require()`-loaded in the browser sandbox.","triggerScenarios":"A parcel plugin/config tries to `require()` a package that is not one of the pre-bundled `@parcel/*` plugins; resolving succeeds to a path but the package isn't in `BUILTINS`.","commonSituations":"REPL loads a project whose parcel config references a custom/third-party plugin or runtime not bundled into the REPL; a transformer tries to require a helper package at runtime.","solutions":["Only reference parcel plugins that ship in the REPL's BUILTINS list (the standard `@parcel/*` set).","Remove custom `.parcelrc` entries that pull in third-party plugins when running in the REPL.","If you control the REPL build, add the needed package to the BUILTINS map at build time.","Run the build with a local Parcel install instead of the in-browser REPL for non-builtin plugins."],"exampleFix":"// before — .parcelrc references a non-bundled plugin\n{\n  \"transformers\": { \"*.foo\": \"parcel-transformer-foo\" }\n}\n// after — drop it in the REPL\n{ \"extends\": \"@parcel/config-default\" }","handlingStrategy":"validation","validationCode":"import { BUILTINS } from '@parcel/repl/.../BrowserPackageManager.js';\nfunction canRequireInRepl(resolved) { return resolved in BUILTINS; }","typeGuard":"function isBuiltinPlugin(spec) {\n  return typeof spec === 'string' && Object.prototype.hasOwnProperty.call(BUILTINS, spec);\n}","tryCatchPattern":null,"preventionTips":["Constrain REPL projects to the default parcel config.","Avoid third-party parcel plugins in REPL projects.","Extend BUILTINS at build time if a custom plugin is required."],"tags":["repl","browser","parcel-plugin","require"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}