L is not defined error with Leaflet

Switch the order of the two script tags main.js and leaflet.js.

Basically you're instantiating main.js before leaflet.js has been instantiated and therefore L does not exist at runtime for main.js.

 <script src="js/leaflet/leaflet.js"></script>  
 <script src="js/main.js"></script>

I also have an error with L but in this case the error was that in

 <script  src="./leaflet/dist/leaflet.js"></script>

I was writing: <script type="module" src="./leaflet/dist/leaflet.js"></script>


I am using mapbox with reactjs and not using leaflet directly, and in my case I was able to resolve the error message: L is not defined no-undef by simply getting it from the window variables:

var L = window.L;