ChatGPT解决这个技术问题 Extra ChatGPT

How do I get IntelliJ IDEA to display directories?

I've been trying out IntelliJ IDEA for JavaScript editing, and I like it so far, but I'm having a small problem with a new project.

I can't seem to be able to get IDEA to display the directories in the project directory in the Project view. Even if I manually add a directory, it refuses to display it.

I think this probably has something to do with the fact that it tries to apply Java conventions, but when I imported an old Eclipse project, it showed all directories just fine.

Do I have to use Eclipse to create projects and import in IDEA to get the directories visible, or is there some other trick?

I am using IDEA version 8.1.3, and the code is just a plain bunch of HTML and JavaScript files, not in any kind of a Java environment.

Solved, but looks like I need to wait 45 hours to accept my own answer.

R
ROMANIA_engineer

It appears I need to manually create a Java module (File->New Module) inside the project to actually see the "proper" directory view. I do wonder why it didn't show up when I created it with the project.


is there a way to go to a specific folder name like you can for files?
This doesn't work for me. When I try to create a new Java module, IDEA just tries to create a new directory in my source for it. I don't want that. I want to import a PHP module, or something like that.
I did a new Static Web Project because the "Empty Project" did not show the directories. Static Web Project does. This was for a PHP project; the idea of adding a java module for a php project has a distinctly bad smell :)
Static Web Project is not in the list when creating a New project in IDEA 2016.2 :(?
F
FranciscoBouza

I've been struggling with this same problem and found another reason why directories may not show up correctly. Make sure the "Content Root" is correct.

Click on the project

Select "File"->"Project Structure"

Select "modules" from the left column, and select a module.

On the sources tab you will see the current "Content Root" along with a button to add a new content root.

Make sure that content root is correct. When in the project structure view you will only see files below the "Content Root". I'm fairly new to IntelliJ but I think of the content root as the basedir in ant terms.

These instructions are for IntelliJ 9.x

Hope this helps someone.


My project apparently has no "modules", so this doesn't help me.
Thanks a lot! This helped me a lot after searching for 2 hours.
l
lifecoder

Current more straightforward logic:

remove the .idea/ folder

select in Idea File -> New project.

in left menu select Web Module, and then set up project folder

you're done!


Seems not to work with the latest version of IDEA (I see no "Web Module" option), but just choose Java module instead and these instructions will work well to recreate the project (if you've already created it as an empty project) in a way that you can see all the subdirectories.
You need to set up plugin for the "Web Module" option. I think it matters for PHP only, not JS/CSS.
This is the one that worked for me. Strange that IntelliJ is so eager to hide important directories from you.
This worked for me in PhpStorm. I closed PhpStorm, renamed .idea to .idea_ and than started PhpStorm again. Then the IDE created a new .idea folder and the project structure was correctly back again.
I use Static Web Project to do this
C
Community

I found the solution thanks to Thurman Sanders and decided to post a more clear answer, in case it helps anyone else. I know an answer like this would have saved me 5 minutes of fumbling around.

Problem

Some folders are excluded, by default. In most cases, this is exactly what you want. Other times, you need to see your "build" or "target" folder, for example.

Solution

Make Intellij stop excluding the folder you want to see

Open the Module Settings select the module and press F4 or right click the module and choose "open module settings" or press cmd; to open project settings, then select your module Follow the steps in the picture, below: select the 'sources' tab select the folder you want to see disable the 'excluded' option Press OK When you're done, the folder will turn orange and finally be visible in the project view!

https://i.stack.imgur.com/qvNRB.png


clicking it should toggle between selected and deselected. You can also try clicking the X's to the left in the middle section under "Excluded Folders." In the image above, that section is in pink and contains the .gradle and build folders. Clicking the X to the right should have the same effect of removing those items from the excluded folders list.
"In most cases, this is exactly what you want." No! That's a terrible, terrible assumption. The default should be to show the entire project structure, not to hide everything. In some cases I might want to hide build or target, but hiding everything is just a really terrible idea. And the procedure to unhide stuff in IntelliJ is just awful. "Show everything" should be a simple part of the Project view. (In my case, I checked an Angular project out of git, all was hidden, and there were no modules to select.)
For my case: I found that the module (just a static folder) that I was working in wasn't visible in the modules list (for some uknown reason after a restart), so I re-added it and this fixed the issue
v
vikingsteve

Simplest way to do this!

Reading some of the other answers, they require you to go into Project Structure -> Modules and check that the sources are not excluded.

But in my case - there are no modules defined in the project at all, so that didn't help.

To easily create a module for your project and therefore show the folder structure -

Go to File menu -> New -> Project...

Select Static Web. Note: it does not matter if your project is "web" or not!

Hit next, then fill in the same Project Name: and Project location: as you have already.

IntelliJ will say "File Already Exists" - "Would you like to overwrite it?" - answer Yes.

Bam! Your Project Pane with the Project view selected should now instantly show the folder structure of your project.

If you have a maven project, you will need to add the root pom.xml in the Maven Projects window.

And if you want to add java to your project later, you should probably configure a JDK also.


n
neu242

Just use File » New Project » Static Web. All your files and directories will show up.

https://i.stack.imgur.com/90voB.png


Best answer for my problem. Weird that IntelliJ doesn't seem to have a view that displays ALL folders, regardless if they're source / managed or whatever...
simple and works, even if you have existing sources. Just select that directory and intellij will take care of the rest. Tested on Intellij idea 15 for a react-native project.
D
Dax Fohl

File -> Invalidate Caches / Restart worked for me.


Worth mentioning that using this action will result in clearing the IDE's local history. More info: jetbrains.com/idea/help/cleaning-system-cache.html
j
jontyc

The same problem had me going crazy for a couple of hours as well, coming from Netbeans where I could just start a new project and import any source tree. My project is PHP/JS and has nothing to do with Java, so it was not intuitive to have to create a Java module, just so I could see my files listed.

I found the solution (covered above) here for more insight.


M
Mike

Here is how I was able to "display" all folders in my project:

Somehow get to the Project Settings page (for me it was right-click the project then select Modules) Make sure the Sources tab is selected You should see a section in the middle entitled "Excluded Folders" under Source\Folders" Click on the X next to it to remove it from being excluded and it becomes visible.

Hope it this helps.


s
sol

I think this is happening to you as intellij's Project window has the 'Compact Empty Middle Packages' option as checked by default. You will find this option under Setting section of the Projects tab.


Do you have a screenshot?
M
Mr. Wonderful

I had a test folder which wasn't displaying in IntelliJ. It turned out that it had no files in it, IntelliJ was only showing folders that had some files in them. When i manually added files in test folder via Explorer, it reflected back in IDE.


A
Anindya Mukherjee

It happens sometime. You need to go to the configuration (Project Settings) and add the Source folder as content root and then possibly set source/resource etc. from the configuration tab. Apply all the changes and you should be done.


K
Kevin Hutchinson

Just me own 2c. I used "New" -> "Module from existing sources" to get IntelliJ to show folders and files from inside a Github Java project. Hope this helps someone.


A
Alex Zheng

Platform : Intellij2019.3 Macos10.12

The solution is: go to the File - project structure - Modules In the left column, + Add Content Root, and add the folder you hope to use as the root directory. mark the folder you want to compile as source root rebuild

go to the File - project structure - Modules

In the left column, + Add Content Root, and add the folder you hope to use as the root directory.

mark the folder you want to compile as source root

rebuild


T
Trang Nguyen

Just go to View -> Tool windows -> project or Alt+1


S
Sharp

I had a similar problem, this fixed it:

File -> New -> Module from Existing Sources...

I chose the src folder and then it detected the rest on its own.

If you still have issues, try reimporting project by doing:

File -> New -> Project from Existing Sources...


P
Peter Mortensen

In the project explorer window (where all the classes are), switch from "packages" view to "project" view. Then all files, not just classes are displayed.


Thanks but that doesn't seem to be the problem. They don't show up in the project view either