Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6: Failed to compile: Can't resolve 'stream' in ./node_modules/hash-base

I updated three Angular 5 apps to Angular 6 but the last one gives me troubles. Every time i try to compile (serve/build, jit/aot, dev/prod) i get this errror:

ERROR in ./node_modules/hash-base/index.js
Module not found: Error: Can't resolve 'stream' in '[...]/node_modules/hash-base'
ℹ 「wdm」: Failed to compile.

hash-base seems to be a webpack dependency:

@eagle5/[email protected]
└─┬ @angular-devkit/[email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └─┬ [email protected]
        └─┬ [email protected]
          ├─┬ [email protected]
          │ └── [email protected] 
          └─┬ [email protected]
            └── [email protected]  deduped

Some specialties of this app are that i have a framework in ./src beside the app folder and i install a git repository as npm package and import some typescript definitions like so in my tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "paths": {
      "@nettrek/*": [
        "./@nettrek/*"
      ]
    }
  },
  "include": [
    "./src/**/*",
    "./node_modules/@eagle5/player-core/dto/**/*"
  ],
  "angularCompilerOptions": {
    "preserveWhitespaces": false
  }
}

I tried to install this stream npm package but this version doesn't has the stream.Transform extension that hash-base uses.

I tried node 8.11.1 and 10.1.0

like image 809
Icevarta Avatar asked Aug 16 '26 12:08

Icevarta


1 Answers

Ok i found the reason for the error. We used md5.js in one class ourself and forgot to put it in our package.json because it was aleready installed. Md5.js needs of course the node in browser shims that angular 6 no longer supports.

like image 58
Icevarta Avatar answered Aug 19 '26 03:08

Icevarta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!