Earlier today I was building an app and I needed to integrate with Ipinfo and Mapbox-gl.
Mapbox worked just fine inside the development environment but when I deployed to production, gboooooa! An error pop up in the console slapping my face and the map did not display.
What is the error?
Uncaught ReferenceError: y is not defined
Initially, I thought this was a Netlify thing (I deployed to Netlify by the way) until I discovered it wasn't. The error was from the current version of Mapbox - version 2.0.x
What's the fix?
There is no permanent fix for this yet. It's still been worked upon. However there is a work around.
What's the work around?'
Downgrade mapbox-gl
. Yes, that's the work around. You have to downgrade mapbox-gl
to version @1.13.0 for it to work. The error is with version 2.0.x
How to downgrade
First uninstall version 2.0.x in your project
run `npm uninstall mapbox-gl"
then run npm install mapbox-gl@1.13.0
Yeah. You're good to go now.
Happy hacking!
Top comments (2)
@emmanuelthecoder thanks for the suggested workaround!
I've also found another, more consistent solution.
The issue is documented here: docs.mapbox.com/mapbox-gl-js/guide...
In my project I use create-react-app with CRACO, added the follwing settings to craco.config.js :
It is nice to know that there is a better solution for this. Thanks for pointing that out!