I'm in the middle of a course and currently trying to implement mapbox.js . I have followed all of the instructions directly from the mapbox documentation but am receiving an error in the console:
Uncaught ReferenceError: require is not defined
<anonymous> http://localhost:8000/js/mapbox.js:3
Here is my mapbox.js file:
var mapboxgl = require('mapbox-gl/dist/mapbox-gl.js');
mapboxgl.accessToken =
'pk.eyJ1IjoiYnJhbmF1c3QiLCJhIjoiY2tnOHVibGllMDVuYjJ5cHFmbmpucndwZSJ9.KBzYV-QSHSChEb6QJpNpdg';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
});
and I am appending to the head of my base file inside a separate .pug file :
block append head
link(href='https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.css' rel='stylesheet')