question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't resolve 'stream'

See original GitHub issue

What is wrong?

Installing brain.js via npm in an angular framework doesn’t work. Error:

ERROR in ./node_modules/brain.js/dist/train-stream.js
Module not found: Error: Can't resolve 'stream' in '../node_modules/brain.js/dist'

Where does it happen?

When running npm start

How do we replicate the issue?

  • Fresh Project with Angular 7.1.4
  • npm install brain.js
  • npm start

How important is this (1-5)?

5

Expected behavior (i.e. solution)

Brain.js shouldn’t throw this error

Other Comments

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
robertleeplummerjrcommented, Jan 5, 2019

Add this to tsconfig.json (found https://github.com/Stuk/jszip/issues/524):

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

Add this to polyfill.ts (found partly https://github.com/algolia/algoliasearch-client-javascript/issues/691, and above, ty @jordyvanderhaegen):

const w = (window as any);
w.process = {
  env: { DEBUG: undefined },
};
w.Buffer = [];
w.process = { env: { DEBUG: undefined }, version: [] };
w.global = w;

I installed this locally and was able to have the app simply work.

3reactions
jordyvanderhaegencommented, Jan 5, 2019

Ran into the same issue, got it temporarily fixed by adding the following to my index.html :

<script> var global = global || window; var Buffer = Buffer || []; var process = process || { env: { DEBUG: undefined }, version: [] }; </script>

https://stackoverflow.com/questions/50356408/upgrading-to-angular-6-x-gives-uncaught-referenceerror-global-is-not-defined

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'stream' in 'C:\dev\jszip ...
After reading this post I found out that the stream package was missing from my project. You can install it by running the...
Read more >
Module not found: Error: Can't resolve 'stream' in React project ...
I believe changing react-scripts to 4.0.3 and rerunning yarn install or npm install would've fixed this issue. There are several ways to get...
Read more >
Module not found: Error: Can't resolve 'stream' [Solved]
The error "Module not found: Error: Can't resolve 'stream'" occurs because there has been a breaking change in Webpack version 5. To solve...
Read more >
Fail to compile: Can't resolve 'stream' · Issue #1645 - GitHub
I recently upgraded to webpack 5.65.0. @react-pdf/renderer@2.0.21 was working fine before I upgraded. Now 'npm start' gives me this error: ...
Read more >
if you want to include a polyfill, you need to: - add a fallback ...
I had a minor fix, I was able to resolve the stream-browserify error by using npm install stream but ... Module not found:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found