calvinmetcalf / shapefile-js

Convert a Shapefile to GeoJSON. Not many caveats.
http://calvinmetcalf.github.io/shapefile-js/
715 stars 228 forks source link

The constructor with parameters has been removed in JSZip 3.0 #122

Closed aleffabricio closed 4 years ago

aleffabricio commented 4 years ago

Hello when passing a shapefile.zip file returned the following error:

Error: The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.
    at new i (jszip.min.js:13)
    at push../node_modules/shpjs/lib/unzip.js.module.exports (unzip.js:5)
    at Function.push../node_modules/shpjs/lib/index.js.shp.parseZip (index.js:64)
    at index.js:112
    at Array.<anonymous> (browser.js:93)
    at MutationObserver.nextTick (browser.js:57)
    at ZoneDelegate.invoke (zone-evergreen.js:359)
    at Zone.runGuarded (zone-evergreen.js:134)
    at MutationObserver.<anonymous> (zone-evergreen.js:118)

The function I am using:

  shp("assets/shapefile.zip").then(geojson => {
         console.log(geojson);
    }).catch(error => {
          console.log(error);   
    });

@calvinmetcalf Am I doing it wrong or is it a problem in JSZIP builder by version?

calvinmetcalf commented 4 years ago

this package relies on jszip 2.x not 3.0 so I'm not sure how your getting the 3.0 version

aleffabricio commented 4 years ago

In my node_modules global there is a jszip version 3.2.2 which is the default when I create the project, so I downloaded the version to 2.6.4 and it worked, but I use version 3.2.2 for another method you can tell me if Is there any way to point shpjs to your jszzip internal node_modules?

aleffabricio commented 4 years ago

Hello, I managed to fix it, there was a configuration in my tsconfig.json file that led to pointing to root jszip and not the location of shpjs. thank you