node.jstypescriptnode-streams

Module not found: Error: Can't resolve 'stream' or TypeError: stream.Readable is not a constructor


A library I use blob-to-stream need access to node streams. I used to get this error

Module not found: Error: Can't resolve 'stream' in '/mnt/c/Users/jbermudez/workspace/HMI_WEB_CONVERTIDORES/front/node_modules/blob-to-stream'

I set Stream to false as said in this question. Now I get :

TypeError: stream.Readable is not a constructor
at blobToStream (http://localhost:4200/ing-features-recorder.js:1418:12)
at Observable._subscribe (http://localhost:4200/ing-features-recorder.js:6177:25)
at Observable._trySubscribe (http://localhost:4200/vendor.js:87730:25)
at Observable.subscribe (http://localhost:4200/vendor.js:87716:22)
at subscribeToResult (http://localhost:4200/vendor.js:97811:23)
at MergeMapSubscriber._innerSub (http://localhost:4200/vendor.js:93001:116)
at MergeMapSubscriber._tryNext (http://localhost:4200/vendor.js:92995:14)
at MergeMapSubscriber._next (http://localhost:4200/vendor.js:92978:18)
at MergeMapSubscriber.next (http://localhost:4200/vendor.js:88274:18)
at TapSubscriber._next (http://localhost:4200/vendor.js:95153:26)

I use node 14.0 and angular 10 and this is my package.json:

{
  "name": "web-hmi",
  "version": "0.0.0",
  "scripts": {
    "postinstall": "ngcc",
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "test-headless": "ng test --browsers Chromium_no_sandbox --watch=false --code-coverage",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "sonar": "sonar-scanner",
    "clean": "rm -rf node_modules; rm package-lock.json",
    "prenixcodegen": "rm -f src/thrifts/*",
    "nixcodegen": "thrift --gen js:node,ts,es6,with_ns -r -out src/app/core/api/thrifts --I thrifts thrifts/all.thrift",
    "unsecureWeb": "chrome --disable-web-security --incognito --user-data-dir=c:/temp/IC"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~10.0.2",
    "@angular/cdk": "~10.0.2",
    "@angular/common": "~10.0.2",
    "@angular/compiler": "~10.0.2",
    "@angular/core": "~10.0.2",
    "@angular/forms": "~10.0.2",
    "@angular/material": "~10.0.2",
    "@angular/platform-browser": "~10.0.2",
    "@angular/platform-browser-dynamic": "~10.0.2",
    "@angular/router": "~10.0.2",
    "angular-pipes": "^10.0.0",
    "moment": "^2.27.0",
    "rxjs": "~6.5.5",
    "thrift": "git+https://github.com/apache/thrift.git",
    "timers": "~0.1.1",
    "tslib": "^2.0.0",
    "xml2js": "~0.4.23",
    "zone.js": "~0.10.3",
    "ngx-spinner": "^10.0.1",
    "tar-stream": "^2.1.0",
    "blob-to-stream": "^1.0.3",
    "constants": "^0.0.2",
    "pako": "^1.0.11",
    "stream-browserify": "^3.0.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.1",
    "@angular/cli": "~10.0.1",
    "@angular/compiler-cli": "~10.0.2",
    "@angular/language-service": "~10.0.2",
    "@types/node": "~14.0.5",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/puppeteer": "~3.0.1",
    "@types/tar-stream": "^2.1.0",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "puppeteer": "~3.1.0",
    "sonar-scanner": "~3.1.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  },
  "browser": {
    "stream": false
  }
}

Solution

  • Install npm i stream has done the trick for me