Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 'stream' #704

Open
mvoila opened this issue Jul 27, 2020 · 6 comments
Open

Error: Cannot find module 'stream' #704

mvoila opened this issue Jul 27, 2020 · 6 comments

Comments

@mvoila
Copy link

mvoila commented Jul 27, 2020

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.

image
Has somebody experienced the same?
Am i doing something wrong?

Thanks you !

@gadfil
Copy link

gadfil commented Sep 23, 2020

i get same issue

@deindesignpl
Copy link

Same issue

tyfkda added a commit to tyfkda/nesemu that referenced this issue Dec 3, 2020
https://stackoverflow.com/a/55601717

[Error: Cannot find module 'stream' · Issue #704 · Stuk/jszip](Stuk/jszip#704)
tyfkda added a commit to tyfkda/nesemu that referenced this issue Dec 23, 2020
https://stackoverflow.com/a/55601717

[Error: Cannot find module 'stream' · Issue #704 · Stuk/jszip](Stuk/jszip#704)
@boredzo
Copy link

boredzo commented Oct 26, 2021

I'm also encountering this. It occurs when loading the script:

<script src="https://cdn.jsdelivr.net/npm/jszip@3.7.1/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.

@boredzo
Copy link

boredzo commented Oct 26, 2021

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.

@boredzo
Copy link

boredzo commented Oct 26, 2021

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.

@hlovdal
Copy link

hlovdal commented Oct 17, 2022

This seems to be the same as issue #736 which has a suggested solution in one of the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants