25

I'm using jszip v3.2.1 in an angular 7 application. When I build my project (running, for example, npm start) I'm getting the following error:

ERROR in ./node_modules/jszip/lib/readable-stream-browser.js

Module not found: Error: Can't resolve 'stream' in 'C:\dev\jszip-test\node_modules\jszip\lib'

How can I solve this problem?

Ricardo Rocha
  • 14,612
  • 20
  • 74
  • 130

6 Answers6

69

After reading this post I found out that the stream package was missing from my project.

You can install it by running the following command:

npm i stream
Ricardo Rocha
  • 14,612
  • 20
  • 74
  • 130
21

In my case, I wanted to import EventEmitter and added it accidentally from stream package instead of @angular/core package.

Martin Staufcik
  • 8,295
  • 4
  • 44
  • 63
5

This issue encountered when importing web3 to your project. Please follow steps in below article.

https://medium.com/@rasmuscnielsen/how-to-compile-web3-js-in-laravel-mix-6eccb4577666

Fix is:-

Wherever you import the web3 library, change your import from

import Web3 from 'web3'

to import Web3 from 'web3/dist/web3.min.js'

kemparaj565
  • 379
  • 3
  • 6
4

I encountered this error while building an angular library.

It came from my IDE auto-importing EventEmitter from 'stream' instead of '@angular/core' in the library.

Check for:

import { EventEmitter } from "stream";

Update to:

import { EventEmitter } from "@angular/core";
Adavize Aliyu
  • 217
  • 2
  • 9
1

In my case i was importing EventEmitter from 'stream' rather than from '@angular/core'

Umer Baba
  • 285
  • 3
  • 4
0

edit your package.json, change react-scripts to 4.0.3 and run yarn / npm install

Agu Dondo
  • 12,638
  • 7
  • 57
  • 68