Reputation: 1004
I've 2 projects in PhpStorm: one is working well while another won't work and I can't figure what make the first one working.
The first one is working well with library root for bower, npm and composer :
The second one is bower, npm are not detected as library root :
So the behaviour in PhpStorm is different, when I use the navigate file on second project, I see all the vendor file by default :
If I mark the directory as excluded, the ide don't understand the vendor class :
So how can we configure the IDE to mark a directory as library root ?
Upvotes: 35
Views: 19589
Reputation: 5965
Go to File
> Project Structure
Go to Project Settings
> Modules
and remove the library folder (i.e. /node_modules
) from both the Excluded folders and Content root sections.
Your project structure will look like this:
Last, restart IntelliJ.
Go to your project IntelliJ file <your-project>.iml
found on the root folder and remove the lines containing the library path (using /node_modules
as example):
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/dist" />
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
</content>
<content url="file://$MODULE_DIR$/node_modules" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Your project structure should go back to normal.
Upvotes: 1
Reputation: 103
File
> Settings
> Directories
node_modules
entries (right-hand side, x's)Thank you to @Allisone for providing the manual solution.
Based on their response, I was able to replicate the solution using the settings.
Upvotes: 7
Reputation: 9054
Found a solution that worked for me.
I opened the .idea
folder (in sublime), searched all files for the text node_modules
and removed the lines containing it.
In my case I had 2 entries
workspace.xml
<property name="ts.external.directory.path" value="$PROJECT_DIR$/node_modules/typescript/lib" />
project-name.iml
<content url="file://$MODULE_DIR$/node_modules" />
Now my node_modules
directory is automatically marked as library root
again
Upvotes: 10
Reputation: 1004
Thanks to @LazyOne comment, found the solution : Select Preferences | Languages & Frameworks | JavaScript | Libraries and click Add. Select the path you want to add and the folder will be marked as library root. Really useful for non standard path (not bower_components for example)
Upvotes: 30