TypeError ... is not a function

2.7k views Asked by At

I have installed gulp-run-command as follows:

npm install gulp-run-command

I'm running a series of gulp tasks. All the others work, except this one. Here's the task where I'm running gulp-run-command:

var gulp = require('gulp');
var run = require('gulp-run-command');

gulp.task('testTask', run('testString'));

It is directly from the basic usage of gulp-run-command as shown here: https://www.npmjs.com/package/gulp-run-command#usage

I get the following error as I run 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)

What's wrong here?

1

There are 1 answers

1
Steve Waters On

Ok, it worked as I added .default at the end of the line: var run = require('gulp-run-command');

So, like this:

var run = require('gulp-run-command').default