amplify-ui: Cannot find module: 'mapbox-gl'

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Other

How is your app built?

CRA or 3.4.1 or 4.0.3

Please describe your bug.

Creating an optimized production build...
Failed to compile.
./node_modules/react-map-gl/dist/esm/components/map.js
Cannot find module: 'mapbox-gl'. Make sure this package is installed.
You can install this package by running: npm install mapbox-gl.

What’s the expected behaviour?

Should build without issues

Help us reproduce the bug!

Do a prod build with CRA 3 or 4 and @aws-amplify/ui-react package.

Code Snippet

// Put your code below this line.

Additional information and screenshots

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Is there a reason to use the empty-npm-package specifically for satisfying/faking the mapbox-gl peer dependency, aside from that being the suggested answer by the mapbox-gl team? The reason I ask is the package seems sketchy when viewing it on NPM: no README, no repo to view its source, and hasn’t been touched for several years. You can download the tarball from the registry which shows the package is benign, but, looking at it from a supply-chain-security point of view, using what appears to be a random package doesn’t inspire much confidence.

I propose we reform this issue to capture the error of Cannot find module: 'mapbox-gl' since multiple users have reported this problem across, potentially, multiple build tools (here and here). What I’ll ask of users that encounter this error is to provide the following:

  1. Which build tool and version you’re using (Create React App v3.4.1, Next JS v11.1.4, etc.)
  2. Which package manager and version you’re using (npm v8.7.0, Yarn v1.22.17, etc.)