On my Windows Home desktop, I install jszip 3.1.4 with NPM and open this html file with Google Chrome browser (Version 61.0.3163.100 (Official Build) (64-bit)):
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="node_modules/jszip/dist/jszip.js" ></script>
</head>
<body>
<p>Hello</p>
</body>
</html>
Result: "Error: cannot find module 'stream'"
Problem does not occur with Firefox, MS IE, or MS Edge.
Similar to what @mitchwilson found in Issue #464, when I comment out line #1709 module.exports = require("stream"); it works fine. I'm using jszip on client side.
I can't reproduce the issue in my VM (windows 7, Chrome Version 62.0.3202.89 (Official Build) (32-bit)), I get no error in the console.
Do you still have the issue in chrome 62 ? Does it happens on an other computer ?
I can exclude the require('stream'); from the generated file but I would like to understand the cause of the issue here before anything else.
Hi David, yes, the issue is still there with Chrome 62.0.3202.89 (Official
Build).
However, I'm running 64-bit Windows 10 version 1703 (OS Build 15063.674).
I haven't tried it on other computers yet. But my wife's and son's
computers are also Windows 10.
I'm just a retired software engineer / hobbyist, so no need to make it a
priority.
Thanks,
Dave
Dave
On Wed, Nov 8, 2017 at 5:44 PM, David Duponchel notifications@github.com
wrote:
I can't reproduce the issue in my VM (windows 7, Chrome Version
62.0.3202.89 (Official Build) (32-bit)), I get no error in the console.Do you still have the issue in chrome 62 ? Does it happens on an other
computer ?I can exclude the require('stream'); from the generated file but I would
like to understand the cause of the issue here before anything else.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Stuk/jszip/issues/477#issuecomment-342999400, or mute
the thread
https://github.com/notifications/unsubscribe-auth/Af0MBLgkBsf6RJ-oAfmvfAEpO6zRUhsoks5s0jzPgaJpZM4QRwCa
.
I should have access to 64-bit Windows 10 this weekend, I'll try again then.
Do you use a "vanilla" chrome or do you have extensions ? In the latter case, does it still happens if you disable them ?
no need to make it a priority
You have maybe found a serious issue (JSZip not loading at all in chrome). Also, your report is clear, with enough details, show research effort and has a minimalist test case (thank you !). More than enough to be motivated !
I disabled all Chrome extensions, restarted Windows, no change in symptoms.
Dave
On Thu, Nov 9, 2017 at 6:49 PM, David Duponchel notifications@github.com
wrote:
I should have access to 64-bit Windows 10 this weekend, I'll try again
then.
Do you use a "vanilla" chrome or do you have extensions ? In the latter
case, does it still happens if you disable them ?no need to make it a priority
You have maybe found a serious issue (JSZip not loading at all in chrome).
Also, your report is clear, with enough details, show research effort and
has a minimalist test case (thank you !). More than enough to be motivated !—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Stuk/jszip/issues/477#issuecomment-343340711, or mute
the thread
https://github.com/notifications/unsubscribe-auth/Af0MBAVWI8CJpF6z9EdRgspBMGppnWMpks5s052wgaJpZM4QRwCa
.
I tried on a 64-bit Windows 10 (chrome 62), still no issue.
I prepared a possible fix (2c93455), could you try with this file: https://github.com/dduponchel/jszip/blob/issue477/dist/jszip.js ?
That version works - the error does not occur.
Dave
On Sun, Nov 12, 2017 at 1:46 PM, David Duponchel notifications@github.com
wrote:
I tried on a 64-bit Windows 10 (chrome 62), still no issue.
I prepared a possible fix (2c93455
https://github.com/Stuk/jszip/commit/2c93455b28b6aa3db1c9b72491b2e0ff44835e42),
could you try with this file: https://github.com/dduponchel/
jszip/blob/issue477/dist/jszip.js ?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Stuk/jszip/issues/477#issuecomment-343761908, or mute
the thread
https://github.com/notifications/unsubscribe-auth/Af0MBIqhy2TABZFbc7OmVAvkN8NqJwrBks5s10r_gaJpZM4QRwCa
.
Hi,
Is there any updates to this?
I got this problem when updating my Angular app from 5.2 to 6. And angular cli, which now uses Webpack 4. Typesript also updated from 2.6.2 -> 2.7.2.
Same problem like @AnthonNilsson.
After updating to Angular 6 I got this error when compiling:
ERROR in ./node_modules/jszip/lib/readable-stream-browser.js
Module not found: Error: Can't resolve 'stream' in '/myproject/node_modules/jszip/lib'
I could get around the problem by installing "stream" as one of my npm packages manually.
I'm getting this too.
What's happening, at least for me, is that just loading the .min.js file directly into a web browser from a CDN doesn't work because require doesn't exist. At least as far as I can understand the minified code:
var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f
Installing requirejs works around the immediate problem. I don't know what's happening for the offline builder people but I do find myself wondering if the other package systems expose node-style require.
As a plea: some of us can't use offline builders; having a demoduled version would be awesome...
Edit: installing requirejs doesn't solve the immediate problem. It doesn't crash on load any more, but the module never gets installed.
Edit edit: no, that's not quite it. The minified Javascript provides its own require, but the error's because it's trying to call the system one. For some reason it hasn't found the version of stream defined in the jszip code.
Yeah, I have no idea what's going on here.
Aha, got it!
This is, in fact, a _complete red herring_. The code works fine (so far, for me),
What appears to be happening is that it's doing this:
try {
exports.nodestream = !!require('readable-stream').Readable;
} catch (e) {
exports.nodestream = false;
}
readable-stream depends on stream. stream is not in the bundle, so it falls back on a call to external require(). If this doesn't exist an error is logged and an exception thrown. But in jszip, the exception is then caught above and no harm is done, except for the misleading error.
Something else was going wrong in my code, which was causing the jszip symbol not to be inserted into the environment, so I _thought_ it wasn't loading properly even though it was. (Because Javascript browser-side error handling...)
I do see one other call to readable-stream, somewhere to do withNodejsStreamOutputAdapter, but I'm guessing that as I can successfully generate zipfiles I don't need it. We'll see.
But I think this is just cosmetic.
Most helpful comment
I could get around the problem by installing "stream" as one of my npm packages manually.