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

Can't resolve 'stream' #524

Closed
zizizi17 opened this issue May 21, 2018 · 6 comments · Fixed by #614
Closed

Can't resolve 'stream' #524

zizizi17 opened this issue May 21, 2018 · 6 comments · Fixed by #614

Comments

@zizizi17
Copy link

zizizi17 commented May 21, 2018

Hello. After updating the version of Angular to 6.0 I got the next error.

Module not found: Error: Can't resolve 'stream' 
Did anyone have the same?
@jmandreslopez
Copy link

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

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

@dinony
Copy link

dinony commented May 25, 2018

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"]
    }
  }
}

@christophechevalier
Copy link

christophechevalier commented May 29, 2018

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

@mo-norant
Copy link

Thanks @jmandreslopez I did work

@jorroll
Copy link

jorroll commented Oct 29, 2018

@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.

@davidgiven
Copy link

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

mgechev added a commit to mgechev/jszip that referenced this issue Aug 21, 2019
When webpack/rollup or another bundler, implementing the
[`browser-resolve`](https://www.npmjs.com/package/browser-resolve)
spec tries to resolve `jszip` for a browser-based project they fail
with:

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

Since you already produce a browser build, we just need to point to
it inside of `package.json`'s `browser` field.

PS: You'd probably want to double check the semantics of `"."`.

Looking at `browser-resolve` it seems that everything will work
as expected. Also, trying empirically with webpack, everything worked
out, but few more pairs of eyes would be greatly appreciated.

Also @sokra should be able to share a valuable opinion.

Fix Stuk#524
Fix Stuk#521
Fix Stuk#477
oktaal added a commit to UUDigitalHumanitieslab/gretel that referenced this issue Jan 23, 2020
@Stuk Stuk closed this as completed in #614 Apr 1, 2020
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

Successfully merging a pull request may close this issue.

7 participants