我正在尝试测试我的angular 9应用程序,但是在运行ng serve
时遇到错误。它说运行正常,但是当我尝试显示页面时说Cannot GET /
。另外,当我尝试使用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;
~~~~~~~~~~~~
这是我的依赖项:
"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"
}
如果您需要更多信息,我很乐意提供。
答案 0 :(得分:1)
我有同样的问题。 我从app-routing.module.ts中删除了以下导入:
import {patchCallbacks} from "zone.js/lib/browser/browser-util";
(因为它一直未被使用)
这似乎已经解决了问题。
不知道这是否对您有帮助。
答案 1 :(得分:0)
如果您不小心从 'zone.js...' 导入(可能使用 IDE 自动导入)某些内容,则可能会发生这种情况,只需搜索字符串
from 'zone.js
在您的项目中删除它(如果不需要)。