Every so often, my modules “disappear” from my project and only jvmMain and jvmTest are tagged as modules (see screen shot). I can’t find a way to restore my commonMain and jsMain folders as modules. My only solution is to create a new project, setup my modules and then copy the source from the old project into the new folders. I don’t know why this keeps on happening. The version of IntelliJ Ultimate doesn’t matter, since this has been happening throughout several versions. I’ve tried invalidating cache, etc., going to Project Structure and try to add the modules to no avail. This is very irritating.
It is a known bug with
withJava switch in the project structure. For some reason idea recognizes project structure from java compatibility sourcesets, not from kotlin ones. The solution is to open project manager and remove
test sourcesets manually. Here is the issue: https://youtrack.jetbrains.com/issue/KTIJ-701. And another one: https://youtrack.jetbrains.com/issue/KTIJ-17333.