Jszip: Can't resolve 'stream'

Created on 21 May 2018  路  6Comments  路  Source: Stuk/jszip

Hello. After updating the version of Angular to 6.0 I got the next error.
```ERROR in ./node_modules/jszip/lib/readable-stream-browser.js
Module not found: Error: Can't resolve 'stream'
Did anyone have the same?

Most helpful comment

I think that stream is required but not specified as a dependency.
Somehow, I think that readable-stream is used instead of stream when building via grunt, but other build processes do not have that mapping.

I think it's better to:

{
  ...
  "compilerOptions": {
    ...
    "paths": {
      "stream": ["../node_modules/readable-stream/readable.js"]
    }
  }
}

All 6 comments

I resolved that issue by adding the library to the tsconfig.ts like this:

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

I think that stream is required but not specified as a dependency.
Somehow, I think that readable-stream is used instead of stream when building via grunt, but other build processes do not have that mapping.

I think it's better to:

{
  ...
  "compilerOptions": {
    ...
    "paths": {
      "stream": ["../node_modules/readable-stream/readable.js"]
    }
  }
}

@jmandreslopez Not works for me.
@dinony Works fine with readable-stream.

Thanks @jmandreslopez I did work

@dinony

I think it's better to:

I think you're incorrect. That solution will tell every module in your app to load "readable-stream" instead of "stream", which could easily break other packages / have unintended consequences.

@jmandreslopez's solution is, in general, the superior solution for most apps because it only affects how the jszip module is loaded.

I'll also note that both solutions show the path prefixed with ../. The actual path you should include will depend on where your tsconfig.json file is located. It took me a few minutes to figure out what I was doing wrong.

See also #477 which might be the same issue --- tl;dr: probably not an issue, just a misleading cosmetic warning.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

v1nce picture v1nce  路  3Comments

ghigt picture ghigt  路  4Comments

carloscarcamo picture carloscarcamo  路  5Comments

sriramkp picture sriramkp  路  6Comments

mikeiasNS picture mikeiasNS  路  5Comments