Reputation: 471
Quick question. Like many of you do, all my projects are separated by folders, for example project1; project2 and so on.
Now on all of my projects I use Grunt (yes I plan to give a try to Gulp in the future, but Grunt is what I know how to use for now). So as you know having Grunt means that I have to have the node_modules
folder inside each and every project.
Since I use PhpStorm (same as WebStorm but with PHP functionality) it occurred to me that I could just declare on PhpStorm NodeJS as an external library instead of repeating myself doing the usual npm install
on every project folder.
I read the PhpStorm/WebStorm docs and saw some videos, and went through the PhpStorm preferences Language & Frameworks > JavaScript > Libraries and enabled node_modules as a Global Library
Now we need to take into account that THAT SPECIFIC node library (the one declared on WebStorm/PhpStorm) will not have the Grunt library inside (cause it wasn't installed through npm install
).
So I copied the Grunt folders that I had within my usual node_modules
folder, only to declare it also as a global library, but needles to say grunt its not working the error I get is "unable to find local grunt".
Also after this I just did npm install
to generate the node_modules folder with the appropriate Grunt dependencies, and declared THAT folder as a Global library from within PhpStorm/WebStorm. Also Grunt did not work.
So what is the point of having the option of declaring the node_modules
as a library if we're not going to be able to use the other "libraries" inside that folder. Or am I doing something wrong here?
Upvotes: 0
Views: 55
Reputation: 93728
Setting up node_modules
as a global library in IDE (WebStorm, PHPStorm, etc) won't make these modules available from anywhere through require()
calls in runtime. Libraries are only used by the IDE itself for completion/navigation (see https://blog.jetbrains.com/webstorm/2014/07/how-webstorm-works-completion-for-javascript-libraries/).
You still need to install Grunt locally in each project to make Grunt work. You can also try using symlinks (see https://github.com/gruntjs/grunt-cli/issues/10, Fatal error: Unable to find local grunt)
Upvotes: 1