How to unexclude node_modules in 2016.2.2? Follow
Since upgrading to WebStorm 2016.2.2, it's auto-excluding my node_modules folder. Note that this folder contains my source code, it's not generated by `npm install` or similar. The effect is now I can't find files with shift+shift or cmd-shift-o. If I repeat the shortcut (like cmd-shift-o, cmd-shift-o), that toggles "Include non-project files", and then it can find my files.
It doesn't seem possible to "unexclude" my node_modules under Settings -> Directories, my node_modules folder is red, and has Excluded selected, and it's not possible to unselect.
I can double shortcut for now, but is there a better resolution? Thanks!
Please sign in to leave a comment.
Why can't we just cancel automatic exclusion?
We use npm as our front dep injection system, thus all our own packages (named blocks in the screenshot) and external libs are located in a node_modules directory, directly linked in the index.html (../lib/node_modules/xxx/dist/xxx.js).
In order to use npm at full extent, we have a package.json located in that folder. Because we release and npm update our work on our private npm repsitory.
Now we can't use the code completion or research stuff in our own code anymore.
This thread sound similar -- please have a look
Yes, WebStorm 2016.2.2 handles all node_modules directories as npm-installed dependencies (thus, it's excluded automatically and marked as a library root). Sorry for the inconvenience.
The case when node_modules directory may contain application source code (not generated by `npm install`) will be addressed in WebStorm 2016.2.3 (see issue https://youtrack.jetbrains.com/issue/WEB-22909). The following logic is employed to determine whether node_modules directory contains application source code or not: a node_modules directory with a sibling package.json file is considered to contain npm-installed dependencies (it will be excluded automatically and marked as a library); without a sibling package.json - it's assumed to contain application source code.
Will this logic work for you? Thanks
I had the same problem, but I figured out that the node_modules was ignored in Settings > Editor > File Types. Removing it from the ignored files did the trick.
Here I detailed in other post: https://intellij-support.jetbrains.com/hc/en-us/community/posts/203372590/comments/115000133390
p.s. renaming the node_modules folder isn't a desirable solution, this is a large project with a lot of people, it's possible but would probably break a lot of scripts and such. Thanks.
I think that you can right click the node_modules directory -> Mark Directory As -> Cancel Exclusion. Maybe that would work?
Thanks Joey for the reply. Unfortunately they've removed "Mark Directory as" from the right click menu. "Remove BOM" is still there, but "Mark Directory as" previously just above it is now gone. There is an alternate way to do the same thing, under Settings -> Directories, but it's not possible to unselect `node_modules` as Excluded, it just won't let you do it.
It sure does, thanks Andriy for the heads up! Doesn't look like there's a resolution yet but I posted there as well.
The forced exclusion is apparently an intentional change in 2016.2.
I opened this support request (hopefully others can see it): https://intellij-support.jetbrains.com/hc/en-us/requests/746984?flash_digest=6872c6ef00a256fa4855279fef4fbacc3cbfd521&page=1
I can't see it, I get an "oops" error. But good luck!
I'm having the same issue, too. Any feedback on this yet? Also, how do you know it was an intentional change? If it was, it wouldn't surprise me though. I think they should rename WebStorm to WebNanny.
Hi Sergey, yes, that logic will work great! Thank you!
The bug/feature request to fix this is here: https://youtrack.jetbrains.com/issue/WEB-23032
The temporary hack that was suggested to me to work around this is to create another directory in your project and link the actively developed packages there. Works for me, but not ideal.
Just following up, I'm now using 2016.2.3 and it has solved my issues. It's nice to see how responsive JetBrains has been. Best of luck to all who still have issues.
Sorry for the late reply.
>Now we can't use the code completion or research stuff in our own code anymore.
Hmm, that's strange. The code completion should be available in node_modules. It'd be much appreciated if you could provide steps allowing to reproduce your problem. An artificial example project would be just great.
A small question about your project structure: IIUC, your own libraries are npm-installed from your private npm repository. Therefore, `node_modules/your-library/*`files are not under VCS and it shouldn't be modified manually after npm-installation, right?
Thanks, Steve, for the update.Glad it works for you.
@Sergey Simonchik this is a problem for me. I do not want node_modules forced as a library root, because it messes up the global find function. I use the global find with custom scopes excluding node_modules. But ... when node_modules is excluded it FORCES my custom scopes to search in node_modules, greatly slowing down search time. :(
Upgrading to 2016.2.3 fixed the problem for me.
Hi @Sergey Simonchik,
I wasn't available until now, late reply for me too. :)
The problem still exists for us.
We decided to have two separate node_modules:
1. one at the root of the project for build related stuff (gulp etc.)
2. another into lib/node_modules with our own libraries as well as external front libraries (they all are linked into the index.html)
The second one, lib/node_modules is registered into git. Because we want everything to work all the time, even without network (as long as you have the sources, the project works). We also had bad experiences of external lib with same version number but different dist.
When we need to update our own libs (or an external one), the lead dev will npm update, check if everything is ok then commit and push for everyone to pull & use.
We separated the build related stuff and the front lib stuff because of the trillion files we can find in gulp and node modules. We didn't want that to pollute our git (we still have a .7zip package into git we pack and unpack because of lack of trust in the npm system).
Because of the fact node_modules is automatically excluded, it is excluded from global search and sometimes from autocomplete. Webstorm is now an obstacle for the dev: we have to manually search via scopes, or even remember the lib we want and open the file with shift+shift, look in the file and copy&paste the function name.
This is sad. :(
If you still need a sample project I can make one for you but it's difficult to justify the time to my hierarchy, we already had to argue in order for us to have licences for your products, they won't want to hear they slow us.
Thank a lot for the details! IIUC, there is no problem with node_modules at the root of the project. As for lib/node_modules, is there lib/package.json file? If yes, what dependencies/devDependencies does it have declared?
>The second one, lib/node_modules is registered into git.
Thanks, I see, npm is not used here at all. Thus, your project files and lib/node_modules/* files are tracked by the same git repository, right?
We have a package.json yes, because we need to update our own libs (in our private repository) as well as external libs. The lead dev will npm update into /libs then commit on git.
Everything is registered into dependencies, no devDependencies:
Our project files and lib/node_modules/* are indeed in the same git repository. We still use npm as I said above, when we need to update a lib the lead dev will npm update and commit on git.
We have a dozen apps developped by several teams, we rely on npm because when one of our lib is updated (and released on our private repo) we just have to mail the lead devs, make them npm update and push and voilà, all the teams have the latest version of the lib.
the root node_modules have no issues, it is used for build only and Webstorm behaves as expected (excluding it). It is not tracked into git (although we track a pack.7z).
Thanks for the information and sorry for the late reply. Just noticed that your `lib/node_modules` folder is not marked as "library root" on your screenshot (https://intellij-support.jetbrains.com/hc/user_images/DkcAM2okaMFvV01hEYVd8Q.png). It means that the node_modules folder is simply excluded and direct dependencies (declared in lib/package.json under 'dependencies' key) are not indexed.
You've described lifecycle of lib/node_modules updates in detail. Thanks for that. A small question regarding your original problem
> Now we can't use the code completion or research stuff in our own code anymore.
In which files you don't have code completion: your main application or `lib/node_modules/*` files? If it's your main application (that doesn't include `lib/node_modules` IIUC) then enabling ".../lib/node_modules" should probably help.
Sadly this is still not working.
I checked everything in the settings.
But sill no completion and search.
> In which files you don't have code completion: your main application or `lib/node_modules/*` files?
In my main application.
We don't code directly into the lib/node_modules, they are developped and npm released from another git repository.
They are into the project repository for convenience (at least they were, this is not really convenient anymore).
All right, thanks. Regarding your screenshot of "Find in Path" dialog, it's expected that "getFromState" is not found in the "Whole project" scope (which is the same as "Custom | Project files"). Since "getFromState" is defined in a file from "lib/node_modules" library, it should be found in "Custom | Project and Libraries" scope.
As for your second screenshot (not resolving of "CoreService.getFromState" method), is "blocks.core" package declared in `.../lib/package.json` under "dependencies" key?
BTW, what's your WebStorm version?
> Regarding your screenshot of "Find in Path" dialog, it's expected that "getFromState" is not found in the "Whole project" scope (which is the same as "Custom | Project files"). Since "getFromState" is defined in a file from "lib/node_modules" library, it should be found in "Custom | Project and Libraries" scope.
Ok I don't remember it was the case before but I can live with scopes. Thanks it will be easier to work already.
> As for your second screenshot (not resolving of "CoreService.getFromState" method), is "blocks.core" package declared in `.../lib/package.json` under "dependencies" key?
Build #WS-162.1812.21, built on September 4, 2016
Licensed to xxx / Simon Peyou
Subscription is active until xxx
JRE: 1.8.0_91-b15 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
Here's a new information I just saw: we have 2 lib/node_modules in the project.
One for desktop app. One for mobile app. They both have different versions of same libs (as well as other unrelated libs)
Maybe the indexer got lost?
Thanks for your time, Sergey. Really appreciated. :)
Hmm, two "lib/node_modules" is hardly a problem.
Can the problem be reproduced for you locally if all needed files are copied to a new project:
* lib/app.js (which uses "CoreService.getFromState" from "blocks.core")
@Simon Peyou Maybe it'd be better to move this particular discussion to a separate issue in our issue tracker (https://youtrack.jetbrains.com/issues/WEB#newissue) to avoid spamming others. ;)