'Unable to create a new module (module already exists) Intellij
I am trying to create a new module in my project. As soon as I specify the name of the module, Intellij throws "That this module already exists". After I exit the wizard it creates a directory with same module name but doesn't make it a module. I delete the directory and I perform "Invalidate Caches and Restart" but still the error persists.
Solution 1:[1]
I had this issue and went to .idea/modules.xml
, found the path with the name I wanted, and deleted that line (just did ctrl+f with the name). After deleting that line and saving the file, I was able to create the module with that name.
Solution 2:[2]
You can try to perform the following actions:
- Close the IDE and manually remove the module.
- Remove
.idea
folder. - Open IDE and reimport the project.
- Try adding the module once again according to official guide.
If the problem remains contact JetBrains support and attach a compressed log folder along with the project structure tree.
Solution 3:[3]
It is a caching issue . So try something on those lines
Invalidate cache and restart worked for me
But in case it doesn't you can try manually deleting .idea files or re-importing the project .
Solution 4:[4]
I had the same problem when I moved the code to a different directory. Detaching the workspaces, removing .idea
, invalidating caches and so on did not help then.
For me what helped was this: Go to File -> Settings -> Project: workspace -> Project Structure
. There you will see the all the projects you ever opened. And you will also see a button Add Content Root
. There you can specify the new location of the (old) project.
Solution 5:[5]
If you are using Gradle and this is a multi-project layout, which is looks like it is, you shouldn't create modules directly in IntelliJ.
Rather, create the directory manually if it doesn't already exists, create a gradle.build[.kts] file in it if needed, and then add an import statement for it in settings.gradle[.kts]. Then just refresh the Gradle configuration in IntelliJ ("Reimport All Gradle Projects").
Solution 6:[6]
When this issue happens during import of existing project, then --close intellij ide --delete the project in explorer --clone it again --open intellij ide --and try to reimport
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 | hacker |
Solution 2 | Egor Klepikov |
Solution 3 | ArpitA |
Solution 4 | konse |
Solution 5 | Bjørn Vester |
Solution 6 | manoj kumar |