我已按如下方式安装了gulp-run-command:
npm install gulp-run-command
我正在执行一系列gulp任务。所有其他人都在工作,除了这一个。这是我运行gulp-run-command的任务:
var gulp = require('gulp');
var run = require('gulp-run-command');
gulp.task('testTask', run('testString'));
直接来自gulp-run-command的基本用法,如下所示: https://www.npmjs.com/package/gulp-run-command#usage
我运行gulp时出现以下错误:
TypeError: run is not a function
at Object.<anonymous> (c:\mypath\gulp\tasks\common\initLocalJsonSe
rver.js:6:23)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at requireDir (c:\mypath\node_modules\require-dir\index.js:123:33)
at requireDir (c:\mypath\node_modules\require-dir\index.js:76:33)
这里有什么问题?
答案 0 :(得分:0)
好的,我在行末添加var run = require('gulp-run-command');
时有效:var run = require('gulp-run-command').default
所以,就像这样:
arr[0]