angular 8 抛出错误`没有导出成员'ɵBrowserPlatformLocation'。`

angular 8 throw error `has no exported member 'ɵBrowserPlatformLocation'.`

我在将 angular 编译为 :

时遇到错误
ERROR in node_modules/single-spa-angular/src/extra-providers.d.ts:2:10 - error TS2305: Module '"D:/trails/spa-angular-shared/login/node_modules/@angular/common/common"' has no exported member 'ɵBrowserPlatformLocation'.

2 import { ɵBrowserPlatformLocation, LocationChangeEvent } from '@angular/common';
           ~~~~~~~~~~~~~~~~~~~~~~~~

package.json:

{
  "name": "login",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build:single-spa:login": "ng build login --prod --deploy-url http://localhost:4203/",
    "serve:single-spa:login": "ng s --project login --disable-host-check --port 4203 --deploy-url http://localhost:4203/ --live-reload false"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "@angular/common": "~8.2.0",
    "rxjs": "~6.4.0",
    "single-spa": ">=5.4.0",
    "single-spa-angular": "^3.1.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "^8",
    "@angular-devkit/build-angular": "~0.803.10",
    "@angular/cli": "~8.2.0",
    "@angular/compiler-cli": "~8.2.0",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.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": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~5.18.0",
    "typescript": "~3.5.3"
  }
}

问题出在 single-spa-angular 原理图中,已在 v 3.5.3 中修复。如果在 v3.5.3 中已修复,即使您指定之前的版本,它也会安装最新版本。

https://github.com/single-spa/single-spa-angular/releases/tag/v3.5.3

按照以下步骤操作

  1. 删除node_modules.
  2. 删除包-lock.json.
  3. 从 package.json.
  4. 中删除 single-spa-angular 和 single-spa
  5. 运行 ng add single-spa-angular@3.5.3
  6. 运行 npm 安装。
  7. 运行 你的申请。

有关更多信息,您还可以阅读此处:-

https://github.com/single-spa/single-spa-angular/issues/208 https://github.com/single-spa/single-spa-angular/pull/231