问题
If I install any grunt plugin, it is added to a folder named "node_modules" in the root of my project dir per default.
My question: is it possible to move this whole folder (and therefore all plugins) to another location (but still within my project folder), let's say to "build/node_modules" ?
Of course, I still want to be able to run grunt from anywhere in my project hierarchy after this change.
回答1:
Nope, that's a feature of the Node.JS core files. In the case you don't know, Node.JS is the platform which Grunt was built.
All require()
calls which don't point to an absolute file or start with ./
will try to find modules inside node_modules
folders.
回答2:
You can use symbolic link ln -s /original_node_modules_path/node_modules ./node_modules
来源:https://stackoverflow.com/questions/16738177/grunt-possible-to-relocate-node-modules-for-plugins