'Intellij doesn't recognize angular modules, html elements, pipes, and so on
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
Says RouterModule is not an angular module.
No directive is matched for *ngFor and unresolved pipe async.
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",
Solution 1:[1]
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.
Solution 2:[2]
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
The directory should now be marked as library root and everything should be recognized.
Solution 3:[3]
Same problem I faced with the Ionic 5 project.
The Modules are shown or highlighted as error and the HTML, Ionic tags are shown it's not a tag in Intellij Idea ultimate edition.
I follow the mentioned steps as:
- First, delete the
.ideafolder from the project. - Close the IDE.
- Remove the project from the shortcut lists (click on the close button).
- Open via Open -> path of the project ->
- It imports properly.
- Hurray, Projects not shown a single error or highlighted.
Solution 4:[4]
Simpler and tested on IntelliJ 2020:
- delete
.ideafolder for frontend project - go to menu File -> "Invalidate Cache / Restart..." -> click "invalidate cache and restart"
- Let IntelliJ re-index your projet, the problem should be fixed.
This solution should work on IntelliJ 2020 and after.
Solution 5:[5]
An update to Malimo's answer above ^. In the latest version, you manipulate the "Excluded/Not Excluded" flag (here shown as "Excluded" which solved my problem).
Solution 6:[6]
I ran into this issue while running IntelliJ IDEA version 2019.3. I apparently needed to swap JetBrains accounts (from my old work account which was expired to my personal account which had an active license). I downloaded the latest version which is 2021.3.2 and my issue is now resolved.
I believe that updating the latest Angular CLI (13.2.0) is what broke things.
Solution 7:[7]
Actually nothing worked for me, so I had to uninstall and install it again without importing previous settings in new installation.
Solution 8:[8]
Unfortunately for me none of the above worked perse. I had to use a combination of them (the order is important!):
- Invalidate cache/restart.
- Delete the .idea folder
- Restart Pycharm
- Profit
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rhavelka |
| Solution 2 | malimo |
| Solution 3 | Viplav Soni |
| Solution 4 | |
| Solution 5 | Jeffrey Brewster |
| Solution 6 | beefsupreme |
| Solution 7 | Kalhan.Toress |
| Solution 8 | Balu |





