0

I'm getting error TypeError: "plugin-name" is not a function when I try to use more than one gulp plugin.

I'm using Gulp 4

My gulp file

var gulp = require('gulp');
var posthtml = require('gulp-posthtml');

gulp.task('posthtml', function () {
    var plugins = [
        require('posthtml-doctype')({doctype: 'HTML 5'}),
               ('posthtml-alt-always')()
    ];

    var options = { closingSingleTag: 'slash' };

    return gulp.src('*.html')
        .pipe(posthtml(plugins, options))
        .pipe(gulp.dest('./dest'));
});

Error

[08:35:15] TypeError: "posthtml-alt-always" is not a function
    at /Users/jitendra/my-projects/posthtml/gulpfile.js:8:39
    at taskWrapper (/Users/jitendra/my-projects/posthtml/node_modules/undertaker/lib/set-task.js:13:15)
    at bound (domain.js:287:14)
    at runBound (domain.js:300:12)
    at asyncRunner (/Users/jitendra/my-projects/posthtml/node_modules/async-done/index.js:36:18)
    at nextTickCallbackWith0Args (node.js:452:9)
    at process._tickCallback (node.js:381:13)
    at Function.Module.runMain (module.js:449:11)
    at startup (node.js:139:18)
    at node.js:999:3
4

1 回答 1

3

这个语法是怎么回事? require('posthtml-doctype')({doctype: 'HTML 5'}), ('posthtml-alt-always')()

尝试将 require 添加到第二个: require('posthtml-doctype')({doctype: 'HTML 5'}), require('posthtml-alt-always')()

于 2016-04-17T03:17:28.113 回答