jszip
jszip copied to clipboard
Error: Cannot find module 'stream'
Hello,
Get the errror : "Cannot find module 'stream'" when including dist/jszip.min.js in my sourcecode as stated in the documentation : "For a browser, there are two interesting files : dist/jszip.js and dist/jszip.min.js (include just one)."
Not using NodeJS nor npm/bower etc. Platform is : Windows 10, Chrome Version 84.0.4147.89 same with Firefox 78.0.2 and Edge Version 84.0.522.44.
Has somebody experienced the same?
Am i doing something wrong?
Thanks you !
i get same issue
Same issue
I'm also encountering this. It occurs when loading the script:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jszip.min.js"></script>
Was using JSZip 3.5.0, now on 3.7.1 with no change. I'm on Safari 14.1.1 (15611.2.7.1.6) on macOS Catalina. Chrome works, but my tool is a browser-based tool for non-technical users so requiring Chrome isn't an option.
I'm pretty sure this used to work in Safari on High Sierra, but I can't roll back to confirm.
The call stack is:
s (jszip.js:13:586) <- crash point
(anonymous function) (jszip.js:13:671)
(anonymous function) (jszip.js:1733)
s (jszip.js:13:623)
(anonymous function) (jszip.js:13:671)
(anonymous function) (jszip.js:2753)
s (jszip.js:13:623)
(anonymous function) (jszip.js:13:671)
(anonymous function) (jszip.js:3038)
s (jszip.js:13:623)
(anonymous function) (jszip.js:13:671)
(anonymous function) (jszip.js:2761)
s (jszip.js:13:623)
(anonymous function) (jszip.js:13:671)
(anonymous function) (jszip.js:1335)
s (jszip.js:13:623)
(anonymous function) (jszip.js:13:671)
(anonymous function) (jszip.js:1055)
s (jszip.js:13:623)
e (jszip.js:13:791)
(anonymous function) (jszip.js:13:808)
(anonymous function) (jszip.js:13:316)
Global Code (jszip.js:13:321)
s (jszip.js:13:623)
looks to be the module-loading machinery; as near as I can tell, require('./object')
causes require('./utf8')
causes require('./utils')
causes require('./support')
causes require('readable-stream')
(note: no ./
in front of that one) causes require("stream")
(again no ./
) at which point the crash occurs.
It looks like the modules are all organized into an object mapping numbers to pairs of a function and an object defining module names as other numbers in the outer object.
The one that requires readable-stream
defines it as 16; entry 16 is the one that fatally requires stream
, but it defines stream
as… undefined
.
Presumably there's some sort of fallback loading that's supposed to happen, particularly given that it works in Chrome, but that's beyond my understanding of this code.
Also, comparing jszip.js to the contents of the repository, it seems like the module-loading machinery might be generated code. If so, this may be a toolchain (either usage or implementation) issue rather than a bug in jszip code.
This seems to be the same as issue #736 which has a suggested solution in one of the comments.