jszip icon indicating copy to clipboard operation
jszip copied to clipboard

nodestream not supported with 3.3.0 +

Open emps opened this issue 4 years ago • 14 comments

as i use [email protected] nodestream is working and is also supported with my angular 8/9 but as i update it to 3.3.0 nodestream become to false

emps avatar Apr 16 '20 14:04 emps

@mgechev as the author of the PR that went into 3.3.0 could you chime in here?

Stuk avatar Apr 19 '20 23:04 Stuk

Hey @Stuk, I'm lacking context; not sure what does this mean. Steps for reproduction would definitely help.

mgechev avatar Apr 20 '20 19:04 mgechev

just import in Angular Application and u will see that 3.2.0 has support for nodestream and 3.3.0 does not, if u cant do it by some reason let me know

emps avatar May 02 '20 10:05 emps

got the same error. JSzip.generateNodeStream() works well with JSZip 3.2.0, but failed with JSZip 3.3.0 & 3.4.0, throw an error: 'Error: nodestream is not supported by this platform', same as 491

callmeguaishu avatar Jun 02 '20 13:06 callmeguaishu

seems like readable-stream redirect to stream, may be some useful informiation here776

callmeguaishu avatar Jun 05 '20 03:06 callmeguaishu

hope who broke it will fix it, i will keep 3.2.0 till then

emps avatar Jun 14 '20 09:06 emps

We are having the same issue ('Error: nodestream is not supported by this platform') and we are stuck to version 3.2 as well. Is there any news about this?

emaFusco avatar Aug 03 '20 07:08 emaFusco

Yeah PR https://github.com/Stuk/jszip/pull/614 breaks our build too; webpack+electron. I'm using patch-package to revert the change to package.json to fix it for now.

stuarta0 avatar Aug 11 '20 02:08 stuarta0

Just to add that we are also experiencing this issue with Electron.

jthrilly avatar Aug 18 '20 18:08 jthrilly

You can revert https://github.com/Stuk/jszip/pull/614 to get the previous behavior. Looks like doing so will break #524, #521, #477.

mgechev avatar Aug 18 '20 19:08 mgechev

Sure, the workaround of patching the package.json does work, but I'm hoping we can come up with something more sustainable for Electron + webpack users. Seems like I found a fix, which is to use a resolve alias to force the node version of jszip to be bundled when targeting electron-renderer.

In your webpack config, add something like:

module.exports = {
  /// ... other config 
  alias: {
    jszip: require.resolve('jszip/lib/index.js'),
  }  
}

@stuarta0 - this will work for you.

The fundamental problem is that webpack with the electron-renderer target will use the browser field in package.json to bundle the browser version of the library. This in turn will cause any JSZip method that calls nodeStream() to throw this error.

On the surface this is perfectly logical - the nodeStream method isn't available in the browser, and the electron renderer is a modified chromium environment. However, node streams are available in an Electron renderer environment when nodeIntegration is enabled.

Not sure what can be done about the situation, short of better environment detection in the module itself, rather than using the browser property in package.json.

jthrilly avatar Aug 18 '20 21:08 jthrilly

Any update on this issue? Is it still downgrading to 3.2.2 the only solution to use generateNodeStream in a browser environment?

fuscoem avatar Dec 14 '20 09:12 fuscoem

I have same experience in node 14...

vooit avatar May 12 '21 20:05 vooit

Any update on this?

simpros avatar Oct 07 '21 11:10 simpros