0

I'm trying to test my angular 9 application but I'm getting an error when running with ng serve. It says it is running fine but when I try to display the page it says Cannot GET /. Also when I try to build it using ng build it displays the same error message without any useful information in the log.

ERROR in node_modules/zone.js/lib/browser/event-target-legacy.d.ts:9:67 - error TS2304: Cannot find name '_ZonePrivate'.

9 export declare function eventTargetLegacyPatch(_global: any, api: _ZonePrivate): boolean;
                                                                    ~~~~~~~~~~~~
node_modules/zone.js/lib/browser/event-target-legacy.d.ts:10:54 - error TS2304: Cannot find name '_ZonePrivate'.

10 export declare function patchEvent(global: any, api: _ZonePrivate): void;
                                                        ~~~~~~~~~~~~

Here are my dependencies:

"dependencies": {
  "@angular/animations": "~9.1.12",
  "@angular/cdk": "^9.2.4",
  "@angular/cli": "^9.1.12",
  "@angular/common": "~9.1.12",
  "@angular/compiler": "~9.1.12",
  "@angular/core": "~9.1.12",
  "@angular/forms": "~9.1.12",
  "@angular/localize": "~9.1.12",
  "@angular/material": "^9.2.4",
  "@angular/platform-browser": "~9.1.12",
  "@angular/platform-browser-dynamic": "~9.1.12",
  "@angular/router": "~9.1.12",
  "@angular/service-worker": "^9.1.12",
  "@types/showdown": "^1.9.3",
  "ace-builds": "^1.4.9",
  "bootstrap": "^4.5.2",
  "material-icons": "^0.3.1",
  "ngx-showdown": "^5.1.0",
  "rxjs": "~6.6.0",
  "showdown-highlight": "^2.1.5",
  "tslib": "^1.10.0",
  "zone.js": "~0.10.2"
},
"devDependencies": {
  "@angular-devkit/build-angular": "^0.901.12",
  "@angular/compiler-cli": "~9.1.12",
  "@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": "~6.1.0",
  "typescript": "~3.8.3"
}

If you need more information I'm more than happy to provide it.

  • Try upgrading your zone.js to a more recent version like 0.11.2 – Marek W Oct 24 '20 at 21:33
  • It has to do with zone.js, maybe another library "make noize", try to remove other "non angular library" one by one to see if it's working – Twen Oct 24 '20 at 21:35

2 Answers2

2

I had the same problem. I deleted the following import from app-routing.module.ts:

import {patchCallbacks} from "zone.js/lib/browser/browser-util";

(Since it was unused anyway)

And that seems to have solved the problem.

No idea if this might help you.

Bram
  • 21
  • 2
1

It might have happened if you have accidentally imported (maybe with IDE auto import) something from 'zone.js...' Just search for the string

from 'zone.js

or the string

from "zone.js

in your project and remove it (if it is not necessary).