我使用的是Gulp 3.9.1,节点5.7.1,npm 3.10.3和WebStorm 2016.1。当我尝试为我的项目设置gulp时,我收到以下错误:
/usr/local/bin/node /Users/msbauer/Developer/workspaces/provider-data-management/node_modules/gulp/bin/gulp.js --color --gulpfile /Users/msbauer/Developer/workspaces/provider-data-management/gulpfile.js
error: unknown option `--color'
Process finished with exit code 1
当我强制重新扫描任务时:
Failed to list gulp tasks in provider-data-management/gulpfile.js: process finished with exit code 1 (a non-zero exit code means an error)
* Edit settings
$ /usr/local/bin/node /Users/msbauer/Developer/workspaces/provider-data-management/node_modules/gulp/bin/gulp.js --no-color --gulpfile /Users/msbauer/Developer/workspaces/provider-data-management/gulpfile.js --tasks
error: unknown option `--no-color'
Process finished with exit code 1
当我在CLI执行gulp --help
时:
$ gulp --help
Usage: gulp [options] [command]
Commands:
about display version information about availity-workflow project
init initialize project metadata: package.json, bower.json, availity.json and README.md
Options:
-h, --help output usage information
-V, --version output the version number
这几乎就像WebStorm正在加强额外的参数,但是我所拥有的gulp版本并不支持这些参数。
更新
我运行以下内容来安装gulp-cli(我的项目根目录中的第二个):
$ brew install gulp-cli
$ npm install -g gulp-cli
如果我gulp --help
我得到了正确的选择:
$ gulp --help
Usage: gulp [options] tasks
Options:
--help, -h Show this help. [boolean]
--version, -v Print the global and local gulp versions. [boolean]
--require Will require a module before running the gulpfile. This is
useful for transpilers but also has other applications.
[string]
--gulpfile Manually set path of gulpfile. Useful if you have multiple
gulpfiles. This will set the CWD to the gulpfile directory as
well. [string]
--cwd Manually set the CWD. The search for the gulpfile, as well as
the relativity of all requires will be from here. [string]
--verify Will verify plugins referenced in project's package.json
against the plugins blacklist.
--tasks, -T Print the task dependency tree for the loaded gulpfile.
[boolean]
--depth Specify the depth of the task dependency tree.
--tasks-simple Print a plaintext list of tasks for the loaded gulpfile.
[boolean]
--tasks-json Print the task dependency tree, in JSON format, for the
loaded gulpfile.
--color Will force gulp and gulp plugins to display colors, even when
no color support is detected. [boolean]
--no-color Will force gulp and gulp plugins to not display colors, even
when color support is detected. [boolean]
--silent, -S Suppress all gulp logging. [boolean]
--continue Continue execution of tasks upon failure. [boolean]
--log-level, -L Set the loglevel. -L for least verbose and -LLLL for most
verbose. -LLL is default. [count]
which
返回路径/Users/me/Developer/homebrew/bin/gulp
。但如果我运行gulp --color
我仍然会收到错误error: unknown option
- 颜色'`
如果我使用~/Developer/workspace/project/node_modules/gulp-cli/bin/gulp.js --help
的gulp路径进行相同的实验(再次,从CLI),我会得到完全相同的结果:--help
输出正确的选项,但是--color
和{ {1}}失败并出现相同的错误,尽管被列为有效选项。
答案 0 :(得分:0)
我刚才遇到了同样的问题。我将其跟踪到我们的应用程序的一部分,使用commander.js创建自定义CLI。我能够告诉指挥官传递所需的选项。我将不得不发送拉取请求而不是破解node_modules版本。
项目 gulpfile.js:
var cli = require('custom-cli');
项目 \ node_modules \定制CLI \ CLI \ index.js
var program = require('commander');
program.version(manifests.package.json.version);
//WebStorm needs to pass these options to gulp, so commander has to know about them
program.option('--no-color', 'Disable Colors');
program.option('--gulpfile', 'gulpfile');