Intellij 无法识别 angular 模块、html 元素、管道等 [英] Intellij doesn't recognize angular modules, html elements, pipes, and so on

查看:32
本文介绍了Intellij 无法识别 angular 模块、html 元素、管道等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 webpack 的项目中获得 angular 语言支持时遇到问题(不确定这是否重要,但如果没有 webpack,intellij 一切正常),并且这是一个由 java 和 angular 组成的多模块项目应用程序.

I'm having a problem getting angular language support running with a project that uses webpack (not sure if that's important, but without webpack everything works fine in intellij), and which is a multi module project consisting of java and an angular app.

问题是没有一个angular的模块被识别

The problem is that none of angular's modules are recognized

说 RouterModule 不是一个角度模块.

Says RouterModule is not an angular module.

没有与 *ngFor 和 unresolved pipe async 匹配的指令.

No directive is matched for *ngFor and unresolved pipe async.

虽然 MatAutocompleteModule 已正确导入.

Though MatAutocompleteModule is correctly imported.

我已经导入了 BrowserModule、CommonModule,并且该项目运行良好.只是intellij的检测不起作用.

I've imported BrowserModule, CommonModule, and the project works perfectly fine. It's just intellij's detection that doesn't work.

我已经通过 npm 安装了 @angular/language-service.我已经重新启动了 IDE(很多次).

I've installed @angular/language-service via npm. I've restarted the IDE (so many times).

我该怎么做才能让它发挥作用?

What can I do to get this working?

依赖(角度)

"@angular/animations": "~7.2.14",
"@angular/cdk": "~7.3.7",
"@angular/common": "~7.2.14",
"@angular/compiler": "~7.2.14",
"@angular/core": "~7.2.14",
"@angular/forms": "~7.2.14",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "~7.2.14",
"@angular/platform-browser-dynamic": "~7.2.14",
"@angular/router": "~7.2.14",

devDependencies(角度相关)

devDependencies (angular related)

"@angular-devkit/build-angular": "~0.13.0",
"@angular-devkit/build-ng-packagr": "~0.13.0",
"@angular/cli": "7.3.4",
"@angular/compiler-cli": "7.2.14",
"@ngtools/webpack": "7.3.4",
"@angular/language-service": "^7.2.14",
"angular-router-loader": "0.8.5",
"angular2-template-loader": "0.6.2",
"typescript": "3.2.4",

推荐答案

我将给出对我有用的答案(在 jetbrains 支持的帮助下).从intellij 2018 升级到2019 时,您的node_modules/ 目录不能从您的项目中排除,如果是,那么intellij 将无法为您的项目建立索引.

I am going to give an answer for what worked for me (with help of jetbrains support). When upgrading from intellij 2018 to 2019, your node_modules/ directory cannot be excluded from your project, if it is then intellij will have trouble indexing your project.

node_modules/目录创建后,会自动分配到library root的状态,不要乱动,否则intellij会开始把它当作项目中的普通目录.如果您确实要处理它,请删除 .idea/ 目录并通过执行 File > Open > my- 重新打开项目应用.

When the node_modules/ directory is created, it will automatically be assigned to a status of library root and should not be messed with, otherwise intellij will start treating it as a normal directory within your project. If you do fiddle with it, remove the .idea/ directory and re open the project by doing File > Open > my-app.

如果您在执行 npm install 后遇到索引编制缓慢的问题,请删除 .idea/ 目录并再次打开您的项目应该可以解决问题.

If you experience slow indexing after performing an npm install, remov the .idea/ directory and opening your project again should fix the issue.

这篇关于Intellij 无法识别 angular 模块、html 元素、管道等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆