angulartypescript-typingssingle-spa

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


I am getting an error while i compile my angular as :

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"
  }
}

Solution

  • The problem is with single-spa-angular schematics which was fixed in v 3.5.3. It installs latest version even if you specify a version before if was fixed in v3.5.3.

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

    Follow following steps

    1. Delete node_modules.
    2. Delete package-lock.json.
    3. remove single-spa-angular and single-spa from package.json.
    4. running ng add single-spa-angular@3.5.3
    5. Run npm install.
    6. Run your application.

    For more information you can also read here :-

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