错误在../node_modules/@types/node/assert.d.ts:3:68 - 错误 TS1144:预期'{'或';'



当尝试使用ng serve运行angular应用程序时,我得到了这个错误。以下是该项目的详细信息

Angular CLI: 8.2.0
Node: 14.19.1
OS: darwin x64
Angular: 8.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.802.0
@angular-devkit/build-angular     0.802.0
@angular-devkit/build-optimizer   0.802.0
@angular-devkit/build-webpack     0.802.0
@angular-devkit/core              8.2.0
@angular-devkit/schematics        8.2.0
@angular/cdk                      8.1.2
@angular/flex-layout              8.0.0-beta.26
@angular/http                     7.2.15
@angular/material                 8.1.2
@ngtools/webpack                  8.2.0
@schematics/angular               8.2.0
@schematics/update                0.802.0
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.38.0

我有节点版本v14.19.1"@types/node": "^14.14.31",

我能够通过修改package.json中的@types/nodetypescript的版本来解决这个问题。所以typescript@types/node之间存在版本不兼容。下面是我现在在package.json中使用的。

"@types/node": "15.6.1",
"typescript": "3.5.3"

如果您得到类似的tsc编译错误,并验证您的包中有正确的@types/node和typescript的最新版本。

npm -g upgrade typescript

最新更新