Gulp `TypeError: " имя-плагина "не является функцией`

Я получаю ошибку TypeError: "plugin-name" is not a function когда я пытаюсь использовать более одного плагина gulp.

Я использую Gulp 4

Мой глоток

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'));
});

ошибка

[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

1 ответ

Что происходит с этим синтаксисом?require('posthtml-doctype')({doctype: 'HTML 5'}), ('posthtml-alt-always')()

Попробуй предпочесть требование ко второму:require('posthtml-doctype')({doctype: 'HTML 5'}), require('posthtml-alt-always')()

Другие вопросы по тегам