簡體   English   中英

如何使Grunt搜索節點模塊的特定目錄

[英]How to make Grunt search a specific directory for node modules

Grunt在同一文件夾中查找node_modules,但是如何告訴它在其他文件夾路徑中查找? 我希望它在“ ./js/vendor”中查找其模塊

這似乎按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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM