我有一个用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。http://www.scconfigmgr.com/2014/08/22/how-to-get-msi-file-information-with-powershell
安装完这些后,我做了npm install以获取所需的模块。但是当我执行“ ng服务”时,会显示错误。
错误 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已在此版本中更新。但是我如何解决这个问题而不将这个项目从角度版本5迁移到6。我只需要构建并运行该项目。
我尝试从运行项目的节点模块下替换rxjs文件夹。但没有运气。
编辑:我已经卸载了当前版本,并已降级为angular cli版本1.7.4,但错误是相同的。
答案 0 :(得分:1)
错误 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"
对于^
的{{1}},npm安装最新版本的"^5.0.0-beta.14"
,在最新版本中flex-layout
使用felx-layout
。但是由于该项目是RxJS 6
项目,因此它使用的是Angular 5
的早期版本。因此,由于RxJs
不存在,弹性布局无法导入所需的库。
因此,对我有用的解决方案是更改RxJs 6
package.json
然后"@angular/flex-layout": "5.0.0-beta.14"
答案 1 :(得分:0)
尝试重新安装您的应用程序
npm i
如果这不起作用,请尝试删除node_modules文件夹并重新安装。