Closed bhogan-mitre closed 6 years ago
Typescript may be at play here as well: https://stackoverflow.com/questions/38875401/error-ts2304-cannot-find-name-buffer
did npm i --save-dev @types/node
fix it ?
It turns out I already had @types/node
in my dependencies. I was able to use Buffer directly from my Angular component, by specifying "types": ["node"]
in the compilerOptions
of tsconfig.json
and by importing Buffer within the component.
However, that definition of Buffer does not carry through to shp.js
in my node_modules
.
ERROR TypeError: Buffer.isBuffer is not a function
at toBuffer (VM4774 vendor.js:465473)
at Function.push../node_modules/shpjs/lib/index.js.shp.parseShp (VM4774 vendor.js:465595)
To closing the loop here, I recently stumbled upon the solution while looking around for something else. The selected answer here more or less worked for me: https://stackoverflow.com/questions/50371593/angular-6-uncaught-referenceerror-buffer-is-not-defined
The one modification that I made was to require('buffer/')
to reference the npm buffer
package, as suggested on their readme when used without browserify.
Thank you for providing this capability. It looks interesting and I'm trying to get it to work for me.
I am getting a reference error "Buffer is not defined" in
toBuffer
that is called byshp.parseZip
: https://github.com/calvinmetcalf/shapefile-js/blob/master/lib/index.js#L20Is it possible that I am missing a dependency? Is this expected to work in browser, or only via Node directly? This comment on JSZip suggests that may be the issue. https://github.com/Stuk/jszip/issues/196#issuecomment-69503828