简体   繁体   English

VSCODE 无法识别 angular,即使编译成功也到处都是错误

[英]VSCODE not recognizing angular, errors everywhere even if it compiles successfully

I'm trying to load an angular project in vscode, I used to work on this project with no problem, but suddenly vscode started showing errors everywhere in the project.我正在尝试在 vscode 中加载一个 angular 项目,我以前在这个项目上工作没有问题,但突然 vscode 开始在项目中到处显示错误。 I already have angular installed and all the required extensions for it.我已经安装了 angular 及其所有必需的扩展。

在此处输入图像描述

I tried to resolve the problem with npm cache clean , npm ci , and also tried to uninstall @angular/cli but nothing worked for me, the problem still persist.我尝试使用npm cache cleannpm ci解决问题,还尝试卸载 @angular/cli 但对我没有任何作用,问题仍然存在。

The project is compiling and running successfully but the errors don't disappear and I can't get ride of them.该项目正在成功编译和运行,但错误并没有消失,我无法摆脱它们。

I'm not sure why, but I could resolve this issue by uninstalling vscode and installing it again, but in case you have the same problem, please look at this question before applying mine.我不确定为什么,但我可以通过卸载 vscode 并重新安装来解决这个问题,但是如果你有同样的问题,请在应用我的之前先看看这个问题

Edited: : After a while the errors appeared again, so after some researches I found the problem was because of Eslint extension that was not configured with Typescript correctly, so to fix the error I added the command bellow and magically all the errors disappeared:编辑: :过了一会儿错误再次出现,所以经过一些研究我发现问题是因为没有正确配置 Typescript 的 Eslint 扩展,所以为了修复错误我添加了下面的命令并且神奇地所有错误都消失了:

npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin

More info about how to configure Eslint with Typescript here .有关如何在此处使用 Typescript 配置 Eslint 的更多信息。

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

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