错误 TS2305:模块“/node_modules/rxjs/Rx”没有导出的成员“可订阅”
Posted
技术标签:
【中文标题】错误 TS2305:模块“/node_modules/rxjs/Rx”没有导出的成员“可订阅”【英文标题】:error TS2305: Module "/node_modules/rxjs/Rx" has no exported member 'Subscribable' 【发布时间】:2019-02-02 20:01:42 【问题描述】:我有一个以 Angular 5 构建的项目。这是 package.json
"name": "ff-client",
"version": "0.2.0",
"license": "",
"scripts":
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint --type-check",
"e2e": "ng e2e",
"xprecommit": "ng lint --type-check && ng test --single-run --code-coverage",
"xprepush": "ng build --prod",
"i18n": "ng xi18n --i18n-format xlf --output-path src/locale --locale en --progress",
"i18n-merge": "xliffmerge --profile xliffmerge.json",
"browserstack": "ng e2e --no-serve --config protractor.browserstack.conf.js",
"upgrade": "yarn upgrade-interactive --latest",
"build-en": "ng build --prod --e deploy --output-path=dist/en --i18nFile=src/locale/messages.en.xlf --i18nFormat=xlf --locale=en --base-href /en/",
"build-da": "ng build --prod --e deploy --output-path=dist/da --i18nFile=src/locale/messages.da.xlf --i18nFormat=xlf --locale=da --base-href /da/",
"build-fo": "ng build --prod --e deploy --output-path=dist/fo --i18nFile=src/locale/messages.fo.xlf --i18nFormat=xlf --locale=fo --base-href /fo/",
"build-root": "copy dist\\en\\web.config dist\\ && del dist\\en\\web.config && del dist\\da\\web.config && del dist\\fo\\web.config",
"build-prod": "npm run build-en && npm run build-da && npm run build-fo && npm run build-root"
,
"private": true,
"dependencies":
"@angular/animations": "5.2.9",
"@angular/cdk": "^5.2.4",
"@angular/common": "5.2.9",
"@angular/compiler": "5.2.9",
"@angular/core": "5.2.9",
"@angular/flex-layout": "^5.0.0-beta.14",
"@angular/forms": "5.2.9",
"@angular/http": "5.2.9",
"@angular/material": "^5.2.4",
"@angular/platform-browser": "5.2.9",
"@angular/platform-browser-dynamic": "5.2.9",
"@angular/router": "5.2.9",
"@angular/service-worker": "5.2.9",
"@aspnet/signalr": "^1.0.0-rc1-update1",
"@auth0/angular-jwt": "^1.0.0-beta.9",
"@ngrx/effects": "^5.1.0",
"@ngrx/router-store": "^5.0.1",
"@ngrx/store": "^5.1.0",
"@ngrx/store-devtools": "^5.1.0",
"angular-in-memory-web-api": "^0.5.2",
"applicationinsights-js": "^1.0.15",
"core-js": "^2.5.3",
"hammerjs": "^2.0.8",
"moment": "^2.20.1",
"ng-recaptcha": "^3.0.3",
"ng2-file-upload": "^1.3.0",
"ngrx-store-logger": "^0.2.0",
"ngx-perfect-scrollbar": "^5.3.5",
"redux-beacon": "^1.2.1",
"rxjs": "^5.5.8",
"zone.js": "^0.8.26"
,
"devDependencies":
"@angular/cli": "1.7.4",
"@angular/compiler-cli": "5.2.9",
"@angular/language-service": "5.2.9",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~9.4.6",
"chai": "^4.1.2",
"codelyzer": "~4.1.0",
"cucumber": "^4.0.0",
"husky": "^0.14.3",
"jasmine-core": "~2.99.1",
"jasmine-marbles": "^0.2.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.4.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-teamcity-reporter": "^1.0.1",
"ngx-i18nsupport": "^0.12.0",
"protractor": "^5.3.0",
"protractor-cucumber-framework": "^4.2.0",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "2.6.2"
我已经下载了 npm 和 angular-cli.
安装这些之后,我执行了 npm install 来获取所需的模块。但是当我执行“ng serve”时,它会显示错误。
错误 node_modules/@angular/flex-layout/core/typings/observable-media/observa ble-media.d.ts(1,22):错误 TS2305:模块 '"D:/Projects/FlexFunding/app-dk/Clie nt/node_modules/rxjs/Rx"' 没有导出的成员 'Subscribable'。
我现在知道它是 angular 6 并且 rxjs 已在此版本中更新。但是如何在不将该项目从 Angular 版本 5 迁移到 6 的情况下解决此问题。我只需要构建并运行该项目。
我尝试从正在运行的项目中替换节点模块下的 rxjs 文件夹。但没有运气。
编辑:我已卸载当前版本并降级到版本 angular cli 版本 1.7.4 但错误相同。
【问题讨论】:
【参考方案1】:尝试重新安装您的应用程序
npm i
如果这不起作用,请尝试删除 node_modules 文件夹并重新安装。
【讨论】:
【参考方案2】:错误 node_modules/@angular/flex-layout/core/typings/observable-media/observa ble-media.d.ts(1,22):错误 TS2305:模块 '"D:/Projects/FlexFunding/app-dk/Clie nt/node_modules/rxjs/Rx"' 没有 导出成员“订阅”。
在package.json
中的依赖之一是
"@angular/flex-layout": "^5.0.0-beta.14"
对于"^5.0.0-beta.14"
中的^
,npm 安装最新版本的flex-layout
,在最新版本中felx-layout
使用RxJS 6
。但由于该项目是一个Angular 5
项目,它使用了以前版本的RxJs
。因此,flex-layout 无法导入所需的库,因为RxJs 6
不存在。
所以,对我有用的解决方案是更改 package.json
"@angular/flex-layout": "5.0.0-beta.14"
然后npm install
【讨论】:
以上是关于错误 TS2305:模块“/node_modules/rxjs/Rx”没有导出的成员“可订阅”的主要内容,如果未能解决你的问题,请参考以下文章
错误 TS2305:模块“/node_modules/rxjs/Rx”没有导出的成员“可订阅”
模块“react”没有导出成员“SuspenseList”。 TS2305
node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10) 中的错误:错误 TS2305:
node_modules/ng2-toastr/src/toast-container.component.d.ts(1,48) 中的错误:TS2305-/node_modules/@angular/