问题描述
Android Studio中的打开文件"窗口, + + ,默认情况下将搜索所有目录,包括node_modules
目录.这迫使您必须先遍历无尽的公用文件,例如AndroidManifest.xml
,然后再在根目录中找到该文件.
The Open File window in Android Studio, ++, will search all directories by default, including the node_modules
directory. This forces you to have to go through endless common files, like AndroidManifest.xml
, before finding the one in your root directory.
我注意到在my_project.iml
文件中有一个excludeFolder
标记,但是下次我重新构建项目时,我对my_project.iml
文件所做的所有编辑都将被覆盖.
I noticed that in the my_project.iml
file there is an excludeFolder
tag but any edits I make to the my_project.iml
file get overwritten the next time I rebuild the project.
如何在窗口中永久排除node_modules
目录?
How do I exclude the node_modules
directory permanently from coming up in the Open File window?
这是在Android Studio 3.0上.
This is on Android Studio 3.0.
推荐答案
在build.gradle
文件中添加excludeDirs
.
按照 Nilzor的解决方案,正确的方法是将以下内容添加到根build.gradle
文件中:
Add excludeDirs
in your build.gradle
file.
As per Nilzor's solution, the right way to do this is by adding the following to your root build.gradle
file:
apply plugin: 'idea'
idea.module {
excludeDirs += file('node_modules/')
}
现在,重建您的项目并检查您的my_project.iml
文件.您会看到新的excludeFolder
条目:
Now, rebuild your project and check your my_project.iml
file. You'll see the new excludeFolder
entry:
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
</content>
这篇关于如何从Android Studio的“打开文件"窗口中排除目录,例如"node_modules"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!