{"record":{"id":"bc4ee635dbe61988","repo":"angular/components","slug":"markerclusterer-class-not-found-cannot-construct-bc4ee6","errorCode":null,"errorMessage":"MarkerClusterer class not found, cannot construct a marker cluster. Please install the MarkerClusterer library: https://github.com/googlemaps/js-markerclusterer","messagePattern":"MarkerClusterer class not found, cannot construct a marker cluster\\. Please install the MarkerClusterer library: https://github\\.com/googlemaps/js-markerclusterer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/google-maps/map-marker-clusterer/map-marker-clusterer.ts","lineNumber":129,"sourceCode":"\n  async ngOnChanges(changes: SimpleChanges<this>) {\n    const change = changes['renderer'] || changes['algorithm'];\n\n    // Since the options are set in the constructor, we have to recreate the cluster if they change.\n    if (this.markerClusterer && change && !change.isFirstChange()) {\n      await this._createCluster();\n    }\n  }\n\n  ngOnDestroy() {\n    this._markersSubscription.unsubscribe();\n    this._closestMapEventManager.destroy();\n    this._destroyCluster();\n  }\n\n  private async _createCluster() {\n    if (!markerClusterer?.MarkerClusterer && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error(\n        'MarkerClusterer class not found, cannot construct a marker cluster. ' +\n          'Please install the MarkerClusterer library: ' +\n          'https://github.com/googlemaps/js-markerclusterer',\n      );\n    }\n\n    const map = await this._googleMap._resolveMap();\n    this._destroyCluster();\n\n    // Create the object outside the zone so its events don't trigger change detection.\n    // We'll bring it back in inside the `MapEventManager` only for the events that the\n    // user has subscribed to.\n    this._ngZone.runOutsideAngular(() => {\n      this.markerClusterer = new markerClusterer.MarkerClusterer({\n        map,\n        renderer: this.renderer,\n        algorithm: this.algorithm,\n        onClusterClick: (event, cluster, map) => {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/google-maps/map-marker-clusterer/map-marker-clusterer.ts#L111-L147","documentation":"MapMarkerClusterer lazily loads the @googlemaps/markerclusterer library and throws this error if the MarkerClusterer class is still unavailable when it tries to build the cluster. This usually means the optional peer package isn't installed or its import resolved to undefined. Unlike the other guards, this is about a missing dependency, not timing.","triggerScenarios":"ngOnInit or ngOnChanges triggers _createCluster while markerClusterer?.MarkerClusterer is falsy — i.e. the markerclusterer package is not installed, was not bundled (wrong import path/version, e.g. old 'markerclustererplus' or @google/markerclusterer), or a broken lazy import returned undefined.","commonSituations":"Forgetting to install @googlemaps/markerclusterer, installing a similarly named but different package (MarkerClustererPlus, google.maps.MarkerClusterer v1), version mismatch where the default export shape changed, tree-shaking/bundler config dropping the lazy chunk, or ngDevMode disabled so the error is skipped but the cluster silently fails.","solutions":["Install the correct library: npm install @googlemaps/markerclusterer (the one at github.com/googlemaps/js-markerclusterer).","Import as documented: the component loads markerClusterer lazily; if importing manually ensure 'import * as markerClusterer from @googlemaps/markerclusterer' shape matches, and rebuild.","Remove conflicting packages (markerclustererplus, @google/markerclusterer) that shadow or break resolution.","Check bundler config (Angular builder defaults are fine; custom webpack may need to include the dynamic import).","Verify the installed version is compatible with @angular/google-maps (markerclusterer >= 2.x)."],"exampleFix":"// before\nnpm install markerclustererplus\n// after\nnpm install @googlemaps/markerclusterer","handlingStrategy":"validation","validationCode":"// at build time / app init\nimport * as mc from '@googlemaps/markerclusterer';\nif (!mc?.MarkerClusterer) {\n  throw new Error('@googlemaps/markerclusterer is required for <map-marker-clusterer>');\n}","typeGuard":"function hasMarkerClusterer(lib: typeof import('@googlemaps/markerclusterer') | undefined)\n  : lib is typeof import('@googlemaps/markerclusterer') & { MarkerClusterer: unknown } {\n  return !!lib?.MarkerClusterer;\n}","tryCatchPattern":"try {\n  await clustererInstance._createCluster();\n} catch (e) {\n  if ((e as Error).message.includes('MarkerClusterer class not found')) {\n    console.error('Install @googlemaps/markerclusterer');\n  } else { throw e; }\n}","preventionTips":["npm install @googlemaps/markerclusterer (correct package name).","Remove shadowing packages like markerclustererplus.","Pin a compatible version (>=2.x).","Test clusterer rendering in CI so missing deps fail loudly.","Check bundler config doesn't drop the lazy import."],"tags":["angular","google-maps","missing-dependency","markerclusterer"],"backgroundTag":"missing-peer-dependency","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}