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.
7 Answers
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.
-
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.
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.
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 .
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").
-
-
First you should get it working in pure Gradle (without IntelliJ). If you are new to Gradle, you can take a look at the user guide to get an understanding of how to configure new modules. If this is an existing project you are adding to, you can take inspiration for how it is done for one of the other modules. Once that is working, go back to IntelliJ and press the icon with the two arrows in the Gradle tool window (see this. May 29, 2020 at 12:48
I've started the project on Linux with root account and then this problem appeared when I've switched to user account.
For me changing the ownership of files in project directory worked.
sudo chown -R your_username:your_user_group project_directory
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