Trying to load a taluka.geojson

With reference to this post here [this guys post with require][1]

I am sure my GeoJSON file works [Here is a sample][2]

Here is my code:

    <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>
    <script src="./example-jquery-cdn-master/www/js/lib/require.js"></script>
        #mapid {
            height: 800px;

    <div aria-role="Country Map" id="map"></div>

    //Loading the data State Shapes
    var json = require('./taluka.geojson'); //with path
    // because the path is in json,passed json as a variable
    var statesData = (json, cb) => {
        fs.readFile(require.resolve(json), (err, data) => {
            if (err)
                cb(null, JSON.parse(data))

    // Displaying Maps
    var mapboxAccessToken =
    var map = L.map('map').setView([37.8, -96], 4);

    L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=' + mapboxAccessToken, {
        id: 'mapbox/light-v9',
        attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
        tileSize: 512,
        zoomOffset: -1



Here is the error:

require.js:168 Uncaught Error: Module name "taluka.geojson" has not been loaded yet for context: _. Use     
    at makeError (require.js:168)    
    at Object.localRequire [as require]

Here is my file structure just in case:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.