找不到模块:错误:无法解析“流”或 TypeError:stream.Readable 不是构造函数
Posted
技术标签:
【中文标题】找不到模块:错误:无法解析“流”或 TypeError:stream.Readable 不是构造函数【英文标题】:Module not found: Error: Can't resolve 'stream' or TypeError: stream.Readable is not a constructor 【发布时间】:2020-12-16 06:57:31 【问题描述】:我使用的库blob-to-stream 需要访问节点流。我曾经得到这个错误
找不到模块:错误:无法解析“流” '/mnt/c/Users/jbermudez/workspace/HMI_WEB_CONVERTIDORES/front/node_modules/blob-to-stream'
如this question 中所述,我将 Stream 设置为 false。现在我明白了:
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)
我使用节点 14.0 和 angular 10,这是我的 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
【问题讨论】:
【参考方案1】:安装npm i stream
帮我解决了问题
【讨论】:
以上是关于找不到模块:错误:无法解析“流”或 TypeError:stream.Readable 不是构造函数的主要内容,如果未能解决你的问题,请参考以下文章
在 src/app 外部定义的模块显示错误“找不到模块:错误:无法解析 './' in”