Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Zip.js function does not work on a angular implementation of the project

Open
#77 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, javascript
Domain
frontend

Research direction

Start by inspecting src/zip.js at line 33 and follow how src/download.js invokes it when imported from an Angular application. Reproduce the reported ReferenceError with the shown shp.download call, then verify that the browser download completes without the process error.

Written by the indexing model from the issue text.

Description

Hi guys, the zip function inside zip.js does not work in a angular implementation of this package, it returns the following error:

MeusMapasDetailComponent.html:497 ERROR ReferenceError: process is not defined
    at push../node_modules/shp-write/src/zip.js.module.exports (zip.js:33)
    at Object.push../node_modules/shp-write/src/download.js.module.exports [as download] (download.js:4)
    at MeusMapasDetailComponent.push../src/app/cliente-basico/modules/meus-mapas/detail/detail.component.ts.MeusMapasDetailComponent.exportshp (detail.component.ts:908)
    at Object.eval [as handleEvent] (MeusMapasDetailComponent.html:497)
    at handleEvent (core.js:23107)
    at callWithDebugContext (core.js:24177)
    at Object.debugHandleEvent [as handleEvent] (core.js:23904)
    at dispatchEvent (core.js:20556)
    at core.js:21003
    at HTMLButtonElement.<anonymous> (platform-browser.js:993)
My current implementation
import * as shp from 'shp-write';
  getSingleGeoJson(){
    var selectedPoligon = this.allDrawnItems.getLayer(this.ultimoPoligonoSelecionado.target._leaflet_id);

    var newPoli = L.polygon(selectedPoligon["_latlngs"][0],
      {
        color: '#1DB954',
        fillColor: '#1DB954',
        fillOpacity: 0.2
      }
    ).addTo(this.singlePolygonGroupLayer);

    return this.singlePolygonGroupLayer.toGeoJSON();

  }
  exportshp() {
     var options = {
       folder: 'myshapes',
       types: {
           point: 'mypoints',
           polygon: 'mypolygons',
           line: 'mylines'
       }
  }
      shp.download(this.getSingleGeoJson(), options); 
  }
What i found out

After messing arround i found that the error is in line 33 of the zip.js file inside src, where is has:

 if (!process.browser) {
      generateOptions.type = 'nodebuffer';
    }

since theres no process being set, because the method is being called by a angular project, the download does not happens.

Dominant language
JavaScript
Stars
321
Forks
193
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapbox/shp-write

All issues in mapbox/shp-write

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.