[英]Gulp `TypeError: “plugin-name” is not a function`
I'm getting error TypeError: "plugin-name" is not a function
when I try to use more than one gulp plugin. 我收到错误TypeError: "plugin-name" is not a function
当我尝试使用多个gulp插件时, TypeError: "plugin-name" is not a function
。
I'm using Gulp 4 我正在使用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
What's going on with this syntax? 这种语法是怎么回事? require('posthtml-doctype')({doctype: 'HTML 5'}), ('posthtml-alt-always')()
Try prepending require to the second: require('posthtml-doctype')({doctype: 'HTML 5'}), require('posthtml-alt-always')()
尝试在第二个条件之前添加require: require('posthtml-doctype')({doctype: 'HTML 5'}), require('posthtml-alt-always')()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.