【发布时间】:2016-11-16 08:16:40
【问题描述】:
我正在使用 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--color'`
如果我使用 ~/Developer/workspace/project/node_modules/gulp-cli/bin/gulp.js --help 的 gulp 路径(同样,来自 CLI)进行相同的实验,我会得到完全相同的结果:--help 输出正确的选项,但 --color 和 --no-color 以相同的方式失败错误,尽管被列为有效选项。
【问题讨论】:
-
我自己并不是真正的 gulp 用户(还 - 刚刚开始学习/使用它).. 但我已经安装了
gulp-cli(全球;根据 official documentation)它是 v1 .2.1(最新版本)。如果我这样做gulp --help.. 我确实看到了不同的输出,其中--color选项受支持。我相信您的gulp只是 gulp 本身,而您还需要gulp-cli(这就是 IDE 必须用来运行 gulp 任务的东西)。 P.S. 节点 4.4.4; npm 2.15.1(捆绑一个)。 -
就是这样!将此添加为答案,我会接受。
-
我收回了。当我从 CLI 执行
--help时,它添加了选项,但如果我真的尝试从 CLI 或 WebStorm 运行它,我仍然会收到相同的错误 -
所以它一定是调用错误
gulp.js- 看看你是否可以在那里指定正确的路径。顺便说一句——在那之后你有没有尝试过重新启动 IDE?它可能仍然只是使用旧的(旧的 PATH)。也可以尝试全新的项目(尽可能完成最简单的任务——看看结果如何)。 -
P.S.您还可以升级到最新的稳定版 WebStorm 2016.2(昨天或前一天发布)。也许它会在没有
--color选项的情况下执行不同的命令?
标签: javascript node.js gulp webstorm