gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.33k stars 506 forks source link

TypeError: Class extends value undefined is not a constructor or null #455

Closed maulikpatel-in closed 9 months ago

maulikpatel-in commented 9 months ago

` zip-file/node_modules/@zip.js/zip.js/dist/zip-fs.js:424 class Crc32Stream extends TransformStream { ^

TypeError: Class extends value undefined is not a constructor or null at file:///Users/maulikpatel/Documents/dev/dakshay/zip-file/node_modules/@zip.js/zip.js/dist/zip-fs.js:424:28 at file:///Users/maulikpatel/Documents/dev/dakshay/zip-file/node_modules/@zip.js/zip.js/dist/zip-fs.js:4:77 at file:///Users/maulikpatel/Documents/dev/dakshay/zip-file/node_modules/@zip.js/zip.js/dist/zip-fs.js:5:3 at ModuleJob.run (internal/modules/esm/module_job.js:145:37) at async Loader.import (internal/modules/esm/loader.js:182:24) at async Object.loadESM (internal/process/esm_loader.js:68:5) `

I'm using npm i @zip.js/zip.js and just import library with:

` // tried first: import * as zip from "@zip.js/zip.js";

// tried second: import * as zip from "./node_modules/@zip.js/zip.js/dist/zip-fs.js"; `

node version: v12.22.3

gildas-lormeau commented 9 months ago

The runtime you're using does not support the TransformStream API. You can circumvent this issue by importing web-streams-polyfill in your project and add the required classes into globalThis, see below.

var streams = require("web-streams-polyfill/ponyfill");

globalThis.ReadableStream = streams.ReadableStream;
globalThis.WritableStream = streams.WritableStream;
globalThis.TransformStream = streams.TransformStream;