【发布时间】:2016-03-18 04:50:28
【问题描述】:
你能帮帮我吗
我无法弄清楚过去两天我的 gulpfile 出了什么问题。
谷歌帮不了我...
我有简单的门,gulpfile...
https://github.com/di3orlive/cleanProject
我和我的 2 个朋友有同样的错误,但 linux 上的一个人没有
我们都用win10
节点 5.9.0
npm 3.7.3
吞咽 3.9.1
var gulp = require('gulp'),
del = require('del'),
wiredep = require('wiredep').stream,
gutil = require('gulp-util'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
webserver = require('gulp-webserver'),
notify = require("gulp-notify"),
imageop = require('gulp-image-optimization'),
htmlmin = require('gulp-htmlmin'),
minify = require('gulp-minify'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
cssnano = require('cssnano');
gulp.task('clean', function () {
del.sync(['./www/**']);
});
gulp.task('build', ['clean'], function (){
////COPY_REST///////////////////////////////////////////////////////////////////////////////////////////////////////////
gulp.src(['!./src/scss/**', '!./src/js/**', '!./src/**/*.html', './src/**'])
.pipe(gulp.dest('./www/'));
////BOWER///////////////////////////////////////////////////////////////////////////////////////////////////////////////
gulp.src('./src/**/*.html')
.pipe(plumber({errorHandler: reportError}))
.pipe(wiredep({directory: './src/bower/'}))
.pipe(gulp.dest('./src/'));
////STYLE///////////////////////////////////////////////////////////////////////////////////////////////////////////////
gulp.src(['./src/scss/all.scss'])
.pipe(plumber({errorHandler: reportError}))
.pipe(sass())
.pipe(concat('main.css'))
.pipe(gulp.dest('./www/css/'))
.pipe(postcss([
autoprefixer,cssnano
]))
.pipe(rename({suffix: '-min'}))
.pipe(gulp.dest('./www/css/'));
////JS//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
gulp.src(['./src/js/main.js', './src/js/**/*.js'])
.pipe(plumber({errorHandler: reportError}))
.pipe(concat('main.js'))
.pipe(gulp.dest('./www/js/'))
.pipe(minify())
.pipe(gulp.dest('./www/js/'));
////HTML_MIN////////////////////////////////////////////////////////////////////////////////////////////////////////////
gulp.src('./src/**/*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('./www/'));
});
gulp.task('imin', function() {
gulp.src('./src/i/**/*.*')
.pipe(imageop({
optimizationLevel: 5,
progressive: true,
interlaced: true
})).pipe(gulp.dest('./src/imin/')).on('end').on('error');
});
gulp.task('webserver', function () {
gulp.src('./www/')
.pipe(webserver({
livereload: true,
port: 11111,
open: 'index.html',
directoryListing: {
enable: true,
path: './www/'
}
})
)
});
gulp.task('release', function () {
var number = gutil.env.number;
//gulp release --number 0.1
if (fs.existsSync('./releae/' + number)){
return console.error('Number ' + number + ' already exists')
}
console.log('Making release ' + number + ' ');
gulp.src('./www/**/*.*')
.pipe(gulp.dest("./releases/" + number + '/'));
});
gulp.task('default', function () {
gulp.run(['clean', 'build', 'webserver']);
gulp.watch('./src/**/*.*', ['build']);
});
//======================================================================================================================
var reportError = function (error) {
notify({
title: 'Error',
message: 'Check the console.'
}).write(error);
console.log(error.toString());
this.emit('end');
};
和包装
{
"name": "di3orlive",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "di3orlive",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^6.3.3",
"cssnano": "^3.5.2",
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-htmlmin": "^1.3.0",
"gulp-image-optimization": "^0.1.3",
"gulp-minify": "0.0.5",
"gulp-notify": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-postcss": "^6.1.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.2.0",
"gulp-util": "^3.0.7",
"gulp-webserver": "^0.9.1",
"wiredep": "^3.0.0"
}
}
错误
D:\WORK\OPEN\DI3>gulp
[21:08:52] Using gulpfile D:\WORK\OPEN\DI3\gulpfile.js
[21:08:52] Starting 'default'...
gulp.run() has been deprecated. Use task dependencies or gulp.watch task triggering instead.
[21:08:52] Starting 'clean'...
[21:08:52] Finished 'clean' after 2.61 ms
[21:08:52] Starting 'build'...
[21:08:53] Finished 'build' after 19 ms
[21:08:53] Starting 'webserver'...
[21:08:53] Webserver started at http://localhost:11111
[21:08:53] Finished 'webserver' after 7.91 ms
[21:08:53] Finished 'default' after 127 ms
[21:08:53] gulp-notify: [Error] Check the console.
TypeError: must start with number, buffer, array or string
[21:08:53] gulp-notify: [Error] Check the console.
Error: write after end
[21:08:53] Starting 'clean'...
[21:08:53] Finished 'clean' after 13 ms
[21:08:53] Starting 'build'...
[21:08:53] Finished 'build' after 4.09 ms
[21:08:53] gulp-notify: [Error] Check the console.
Error: ENOENT: no such file or directory, chmod 'D:\WORK\OPEN\DI3\www\js\main.js'
events.js:154
throw er; // Unhandled 'error' event
^
Error: EEXIST: file already exists, mkdir 'D:\WORK\OPEN\DI3\www'
at Error (native)
【问题讨论】:
-
你遇到什么错误..?