简体   繁体   中英

error TS2304: Cannot find name '_ZonePrivate'

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.

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM