OssertionError在Gulp 4.0.0上
运行 npm运行开始
时发生了错误。我的节点版 14.15.0
npm版本 8.7.0
错误
> package.json
{
"name": "froala-design-blocks",
"version": "2.0.1",
"description": "An amazing collection of over 170 ready to use design blocks based on Bootstrap.",
"keywords": [
"froala",
"froala design blocks",
"html design",
"bootstrap",
"material design",
"html templates",
"website design",
"html5",
"trending design"
],
"homepage": "https://www.froala.com/design-blocks",
"license": "https://github.com/froala/design-blocks/blob/master/LICENSE",
"repository": {
"type": "git",
"url": "git://github.com/froala/design-blocks.git"
},
"maintainers": [
{
"name": "Froala Labs"
}
],
"scripts": {
"screenshots": "gulp screenshots",
"start": "gulp",
"zip": "gulp zip",
"dist": "gulp dist && gulp zip"
},
"devDependencies": {
"del": "^3.0.0",
"fs-extra": "^4.0.3",
"gulp": "^4.0.0",
"gulp-connect": "^5.6.1",
"gulp-copy": "^1.1.0",
"gulp-cssmin": "^0.2.0",
"gulp-open": "^2.1.0",
"gulp-pug": "^3.3.0",
"gulp-rename": "^1.4.0",
"gulp-sass": "^4.0.2",
"gulp-util": "^3.0.8",
"gulp-watch": "^4.3.11",
"gulp-zip": "^4.2.0",
"node-sass": "^4.9.3",
"puppeteer": "^0.12.0"
},
"dependencies": {
"bootstrap": "^4.1.3",
"jquery": "^3.3.1",
"popper.js": "^1.14.4",
"vinyl-paths": "^2.1.0"
},
"main": "dist/index.html",
"npmName": "froala-design-blocks",
"npmFileMap": [
{
"basePath": "/dist",
"files": [
"*.html",
"css/*.css",
"imgs/*.jpg",
"imgs/*.png",
"imgs/*.svg"
]
}
]
}
gulpfile.js
var gulp = require('gulp');
var watch = require('gulp-watch');
var sass = require('gulp-sass');
var copy = require('gulp-copy');
var connect = require('gulp-connect');
var del = require('del');
var vinylPaths = require('vinyl-paths');
var utils = require('./utils');
var pug = require('gulp-pug');
var fs = require('fs');
var path = require('path');
var cssmin = require('gulp-cssmin');
var rename = require('gulp-rename');
var zip = require('gulp-zip');
function getBlocks(dir) {
return fs.readdirSync(dir)
.filter(function(file) {
return fs.statSync(path.join(dir, file)).isFile();
})
.map(function (file) {
return ' ' + fs.readFileSync(path.join(dir, file), "utf8").split('\n').join('\n ');
})
}
var build = function (dest) {
gulp.task('clean-' + dest, function () {
del.sync(dest + '/**/*');
})
gulp.task('sass-' + dest, function () {
gulp.src(['src/scss/froala_blocks.scss'])
.pipe(sass())
.pipe(gulp.dest(dest + '/css'))
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(dest + '/css'))
});
gulp.task('html-' + dest, function () {
gulp.src(['src/html/index.html', 'src/html/css.html'])
.pipe(gulp.dest(dest))
})
gulp.task('imgs-' + dest, function () {
gulp.src(['src/imgs/**/*'])
.pipe(gulp.dest(dest + '/imgs'))
})
gulp.task('pug-' + dest, function () {
var blocks = {}
var blks = ['call-to-action', 'contacts', 'contents', 'features', 'footers', 'forms', 'headers', 'pricings', 'teams', 'testimonials']
for (var i = 0; i < blks.length; i++) {
blocks[blks[i]] = getBlocks('src/html/' + blks[i])
}
var LOCALS = {
blocks: blocks
};
gulp.src('./src/html/**/*.pug')
.pipe(pug({
locals: LOCALS,
pretty: true
}))
.pipe(gulp.dest(dest))
})
}
build('.tmp');
build('dist');
gulp.task('watch', [], function() {
watch('dist').pipe(connect.reload());
watch('src/html', function () {
gulp.start(['pug-.tmp']);
})
watch('src/pug', function () {
gulp.start(['pug-.tmp']);
})
watch('src/imgs', function () {
gulp.start(['imgs-.tmp']);
})
watch('src/scss', function () {
gulp.start(['sass-.tmp']);
});
})
gulp.task('zip', () =>
gulp.src('dist/**/*')
.pipe(zip('froala-design-blocks.zip'))
.pipe(gulp.dest('./'))
);
gulp.task('connect', function () {
connect.server({
root: ['.tmp', 'node_modules', 'screenshots'],
port: 8001
});
});
gulp.task('screenshots', function(cb) {
del.sync('./screenshots');
utils.makeScreenshots([
['call-to-action', 'header, section, footer'],
['contacts', 'header, section, footer'],
['contents', 'header, section, footer'],
['features', 'header, section, footer'],
['footers', 'header, section, footer'],
['forms', 'header, section, footer'],
['headers', 'header, section, footer'],
['pricings', 'header, section, footer'],
['teams', 'header, section, footer'],
['testimonials', 'header, section, footer'],
]).then(function() {
cb();
});
});
gulp.task('dist', ['clean-dist', 'html-dist', 'pug-dist', 'imgs-dist', 'sass-dist']);
gulp.task('default', ['clean-.tmp', 'html-.tmp', 'pug-.tmp', 'imgs-.tmp', 'sass-.tmp', 'connect', 'watch']);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论