简体   繁体   English

Gulp dest不能在Windows7中运行

[英]Gulp dest not working in Windows7

The setup 设置

I've followed this tutorial for installing Gulp and configuring a gulpfile.js to concatenate and minify JavaScript files. 我已按照本教程安装Gulp并配置gulpfile.js来连接和缩小JavaScript文件。 I am using a Windows7 machine. 我正在使用Windows7机器。 When I run the gulp command, I get this output: 当我运行gulp命令时,我得到这个输出:

Gulpfile运行没有错误

There are no errors, but gulp.dest() doesn't create the expected "dist/js/MATRIX.min.js". 没有错误,但gulp.dest()不会创建预期的“dist / js / MATRIX.min.js”。

Here is my gulpfile: 这是我的gulpfile:

/* based on http://sixrevisions.com/web-performance/improve-website-speed/ */

var gulp = require('gulp');
var minifycss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var concatcss = require('gulp-concat-css');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var imagemin = require('gulp-imagemin'),
    svgmin = require('gulp-svgmin');


//gulp.task('default', ['css', 'js', 'img', 'svg', 'html'], function () {});
gulp.task('default', ['js'], function () {});

// CSS concatenation + minification task
gulp.task('css', function() {
  return gulp.src('sourcecode/css/*.css')
    .pipe(concatcss('semeano.min.css'))
    .pipe(minifycss())
    .pipe(gulp.dest('dist/css'));
});

// JS linting + minification + concatenation task
gulp.task('js', function() {
    return gulp.src([
        'sourcecode/js/agregate/modernizr.custom.08680.min.js',
        'sourcecode/js/agregate/jquery.js',
        'sourcecode/js/agregate/jquery-ui.js',
        'sourcecode/js/agregate/bootstrap.js',
        'sourcecode/js/agregate/jquery.dataTables.js',
        'sourcecode/js/agregate/dataTables.tableTools.js',
        'sourcecode/js/agregate/ZeroClipboard.js',
        'sourcecode/js/agregate/DT_bootstrap.js',
        'sourcecode/js/agregate/MATRIX_main.js'
    ])
    .pipe(jshint())
    .pipe(jshint.reporter("default"))
    .pipe(uglify())
    .pipe(concat('MATRIX.min.js'))
    .pipe(gulp.dest('dist/js'));
});

// Image optimization task
gulp.task('img', function () {
  return gulp.src('sourcecode/img/*.*')
    .pipe(imagemin())
    .pipe(gulp.dest('dist/img'));
});

// SVG optimization task
gulp.task('svg', function () {
  return gulp.src('sourcecode/svg/*.svg')
    .pipe(svgmin())
    .pipe(gulp.dest('dist/svg'));
});

What I've tried 我试过的

Figuring "I know how to do things", I did some research and came across this "Gulp suddenly not working anymore after npm update" issue , so I tried this suggestion : 想象“我知道怎么做”,我做了一些研究,并发现了这个“Gulp在npm更新后突然不再工作了”的问题 ,所以我尝试了这个建议

  1. Run: "npm install glob@4.2.2" //no problem Run: "npm install glob@4.2.2" //没问题
  2. Run: "npm install" //now I get a bunch of errors: Run: "npm install" //现在我收到一堆错误:

“修复”后的一堆错误

What do I need to do at this point to get this working in my Windows environment? 此时我需要做什么才能在Windows环境中使用它?

From looking at the first screenshot and your code snippet, it looks like gulp.src() isn't finding the files you want to process. 通过查看第一个屏幕截图和您的代码片段,看起来gulp.src()找不到您要处理的文件。 Check to see if you've got any typos like ag g regate? 检查你是否有像ag g regate这样的错别字?

As for that github issue, it refers to an old version of gulp. 至于那个github问题,它指的是旧版本的gulp。 Be sure you're using the latest version of gulp 3.9.0 . 请确保您使用的是最新版本的gulp 3.9.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM