Open catamphetamine opened 3 years ago
This is fixable by updating the 'browser' section of package.json to include "stream": "stream-browserify"
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
$
For some reason, it requires
stream
when bundled with Webpack.