Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij doesn't recognize angular modules, html elements, pipes, and so on

Tags:

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.

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

enter image description here

Says RouterModule is not an angular module.

enter image description here

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

enter image description here

Though MatAutocompleteModule is correctly imported.


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

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

What can I do to get this working?

dependencies (angular)

"@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 (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", 
like image 794
baao Avatar asked Apr 29 '19 11:04

baao


2 Answers

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.

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.

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

like image 179
rhavelka Avatar answered Sep 23 '22 12:09

rhavelka


Had the same problem with IntelliJ 2019.3

But there is a simple solution: right click your node_modules directory -> mark directory as -> cancel exclusion

enter image description here

The directory should now be marked as library root and everything should be recognized.

like image 28
malimo Avatar answered Sep 22 '22 12:09

malimo