OssertionError在Gulp 4.0.0上

发布于 2025-02-09 04:49:31 字数 5472 浏览 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']);

An error occurred on running npm run start. My node version 14.15.0 npm version 8.7.0

Error

gulp error screenshot

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文