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

Module not found: Error: Can't resolve 'stream' in 'xxx\node_modules\jszip\lib' #736

Open
catamphetamine opened this issue Jan 19, 2021 · 2 comments

Comments

@catamphetamine
Copy link

For some reason, it requires stream when bundled with Webpack.

ERROR in ./node_modules/jszip/lib/readable-stream-browser.js 9:0-34
Module not found: Error: Can't resolve 'stream' in 'xxx\node_modules\jszip\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }
 @ ./node_modules/jszip/lib/support.js 35:27-62
 @ ./node_modules/jszip/lib/index.js 40:16-36
 @ blah blah blah

webpack 5.15.0 compiled with 1 error in 688 ms
i 「wdm」: Failed to compile.
@DanielHeath
Copy link

This is fixable by updating the 'browser' section of package.json to include "stream": "stream-browserify"

@hlovdal
Copy link

hlovdal commented Oct 17, 2022

This issue can be closed. I suspect this issue was fixed by #742, at least this problem is present in release 3.5.0 but not in 3.6.0.

Verification:

$ ng new jszip-test
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS
...
$ cd jszip-test/
$ ng test --watch=false
...
TOTAL: 3 SUCCESS

$ npm install jszip@3.5.0
...
$ echo "import * as JSZip from 'jszip';" >> src/app/jszip.spec.ts
$ echo "var zip = new JSZip();" >> src/app/jszip.spec.ts
$ ng test --watch=false
√ Browser application bundle generation complete.

./node_modules/jszip/lib/readable-stream-browser.js:9:0-34 - Error: Module not found: Error: Can't resolve 'stream' in 'C:\test\jszip-test\node_modules\jszip\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }


17 10 2022 16:05:25.252:INFO [karma-server]: Karma v6.4.1 server started at http://localhost:9876/
17 10 2022 16:05:25.256:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
17 10 2022 16:05:25.268:INFO [launcher]: Starting browser Chrome
17 10 2022 16:05:26.185:INFO [Chrome 106.0.0.0 (Windows 10)]: Connected on socket 8ZMpW4xQLJuiCWJ7AAAB with id 66557292
17 10 2022 16:05:26.275:WARN [web-server]: 404: /_karma_webpack_/main.js
Chrome 106.0.0.0 (Windows 10): Executed 0 of 0 SUCCESS (0.006 secs / 0 secs)
TOTAL: 0 SUCCESS

$ npm install jszip@3.6.0
...
$ ng test --watch=false
...
TOTAL: 3 SUCCESS

$

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

3 participants