[Bug] Mapbox geocoder example crashes: "i is not a function"

Open
#2,628 0 comments 0 reactions 0 assignees View on GitHub

@yuiseki is already working on this.

Since Nov 11, 2026.

  • #2629 by @yuiseki — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
node.js, react, typescript, webpack
Domain
frontend, web-dev

Research direction

Start with the website's webpack configuration and how it resolves the nested nanoid dependency used by @mapbox/mapbox-gl-geocoder. Reproduce by opening the Mapbox geocoder example at /examples/mapbox/geocoder and check whether the control renders without the reported TypeError. Done means the example loads with the geocoder control; pull request #2629 is already open against this issue.

Written by the indexing model from the issue text.

Description

Description

The Mapbox geocoder example on the website crashes on load with TypeError: i is not a function.

The error is thrown in generateSessionID() of @mapbox/[email protected], which calls require('nanoid')() and expects nanoid@2. The website's webpack config sets resolve.modules to absolute paths (from @vis.gl/docusaurus-website), so the nested nanoid@2 is skipped and the hoisted nanoid@3 is bundled. nanoid@3 has no default export.

image
Expected Behavior

The example renders a map with the geocoder control.

Steps to Reproduce

Open https://visgl.github.io/react-map-gl/examples/mapbox/geocoder

Environment
Logs
TypeError: i is not a function
    at generateSessionID
    at onAdd
    at addControl
Dominant language
TypeScript
Stars
8.5k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from visgl/react-map-gl

All issues in visgl/react-map-gl

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.