DEV Community 👩‍💻👨‍💻

Emmanuel Aiyenigba
Emmanuel Aiyenigba

Posted on

'Uncaught ReferenceError: y is not defined': how to solve this production Mapbox error


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 (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.