[英]How to make Grunt search a specific directory for node modules
Grunt looks in the same folder for node_modules, but how can I tell it to look in a different folder path? Grunt在同一文件夹中查找node_modules,但是如何告诉它在其他文件夹路径中查找? I want it to look in "./js/vendor" for its modules
我希望它在“ ./js/vendor”中查找其模块
This seems to work as described in the issue #696 on Grunt's GitHub issue tracker. 这似乎按Grunt的GitHub问题跟踪器上的问题696中所述进行工作。
// if you want to overload the directory on the CLI
grunt --dir=<your dir to search>
// example CLI command (relative to Gruntfile)
grunt --dir=${PWD}/js/vendor2
/**
* Add the following code to your
* Gruntfile.
*/
// set the custom or default directory
var customDir = grunt.option('dir') || process.cwd() + '/js/vendor';
// get the current working directory
var cwd = process.cwd();
// switch to custom directory (contains node_modules folder)
process.chdir(customDir);
// load taks(s)
grunt.loadNpmTasks('grunt-browserify2');
// switch back to original directory
process.chdir(cwd);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.