简体   繁体   English

错误 TS2304:找不到名称“_ZonePrivate”

[英]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 .我正在尝试测试我的 angular 9 应用程序,但是在使用ng serve运行时出现错误。 It says it is running fine but when I try to display the page it says Cannot GET / .它说它运行良好,但是当我尝试显示该页面时,它说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.此外,当我尝试使用ng build它时,它会显示相同的错误消息,但日志中没有任何有用的信息。

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:我从 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如果您不小心从 'zone.js...' 导入(也许使用 IDE 自动导入)某些内容,则可能会发生这种情况,只需搜索字符串

from 'zone.js

or the string或字符串

from "zone.js

in your project and remove it (if it is not necessary).在您的项目中并将其删除(如果没有必要)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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