devextreme-angular: Angular 6: Can't resolve 'stream'

  • Specify the version of the devextreme-angular and devextreme packages you are using. devexteme version: 17.2.7 devextreme-angular version: 17.2.7

  • Specify the type of the issue (check one with “x”): [x] bug Report [ ] feature request [ ] support inquiry

We’re trying to upgrade our project to Angular 6, but we see the following error when including any Dx* modules:

ERROR in ./node_modules/jszip/lib/readable-stream-browser.js
Module not found: Error: Can't resolve 'stream' in 'c:\Source\TestProject\node_modules\jszip\lib'

I’ve tried creating a clean Angular 6 project and just adding DevExtreme, but the results are the same.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 14
  • Comments: 42 (2 by maintainers)

Commits related to this issue

Most upvoted comments

This is a change in Angular CLI 6. It’s necessary to register JSZip in the tsconfig.json file as described in the https://github.com/angular/angular-cli/issues/9827#issuecomment-369647555 issue.

{
  ...
  "compilerOptions": {
    ...
    "paths": {
      "jszip": [
        "node_modules/jszip/dist/jszip.min.js"
      ]
    }
  }
}

funny, I did npm install stream and worked for me 😃

module.exports = require(“readable-stream”); //module.exports = require(“stream”);

just replace this line of code in the file (“readable-stream-browser.js”) until it is fixed by Angular/CLI

Installing random packages that happen to have the name of a NodeJS API, but haven’t been updated for 6 years… What a smart choice. Please request from Devextreme to patch this issue instead of “making it work” on your side with band-aids.

Installing npm “stream” works for me.

npm install stream --save

    "paths": {
      "jszip": [
        "../node_modules/jszip/dist/jszip.min.js"
      ]
    }

put 2 dots before “node_modules”

npm install stream --save works for me

npm install stream --save works for me too

npm install stream --save works for me too 😃

npm install stream funciona para mi en angular 7

Still experiencing the same issue with Angular 7, Devextreme ^18.2.3 and ionic 4.

npm install stream --save works for me

Installing npm “stream” works for me.

npm install stream --save

I did npm install stream and worked for me too

it is a bug in “readable-stream” itself, it is missing package stream in the dependencies.

image

you have to install stream npm i stream

npm install stream --save помогло!

it is a bug in “readable-stream” itself, it is missing package stream in the dependencies.

image

you have to install stream npm i stream

Thanks man, sorted it out for me.

installing stream worked.

Can confirm… installing stream sorts this out. Thanks @ardymalihi

The guide to adding DevExtreme to an Angular application has this step defined: JSZip Registration, and it fixes the issue.

The npm package stream is about 5…7 years old in version 0.0.2. (dead) … No, thanks. But for now, solved by adding the path in tsconfig as workaround.

{
  "compilerOptions": {
    "paths": {
      "jszip": ["node_modules/jszip/dist/jszip.min.js"]
    }
  }
}

so installing the stream package seems to be no good idea, but registering JSZip in the tsconfig.json file (as suggested here), does not work for me, because then the build fails with this:

Error:(9, 24) TS7016: Could not find a declaration file for module 'jszip'. 'ROOT/node_modules/jszip/dist/jszip.min.js' implicitly has an 'any' type.

see this Stackoverflow question for details.

So does someone know a solution that fixes both issues?

For me the issue is now solved in jszip version 3.3.0: see Fix browser module resolution #614

I don’t need the outdated stream package or use the JSZip Registration workaround (which broke my typescript type resolution: see SO typescript does not find jszip types)

@GoshaFighten , I tried a bunch of variations of this. And I started to notice the point you made about the path in the error message. But when I got the right amount of ../ in there to get the path correct in the error message, the error message was still there. But then I saw that I added this to tsconfig.app.json instead of tsconfig.json. Once I moved it to the root tsconfig.json, and adjusted the path to node_modules again, this seems to work now. Thanks for taking a look!