gpt4 book ai didi

javascript - 运行 gulp 时出现类型错误。但找不到任何TypeError 是不是Node 和npm 版本有问题?

转载 作者:太空宇宙 更新时间:2023-11-04 01:54:54 32 4
gpt4 key购买 nike

我的 Gulp 文件运行良好,但当我将 Node 6 更新到 8 时,它抛出错误。为了解决这个错误,我回到 Node 6。但在那之后,它显示“TypeError dest.on 不是一个函数”,但我找不到任何 TypeError。谁能告诉我我做错了什么? Node 版本:6.11.4npm 版本:3.10.10下面给出了我的 gulpfile.js

var postcss = require('gulp-postcss');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var livereload = require('gulp-livereload');
var concat = require('gulp-concat');
var minifycss = require('gulp-minify-css');
var autoprefixer = require('autoprefixer');
var gulpAutoprefixer = require('gulp-autoprefixer');
var plumber = require('gulp-plumber');
var sourcemaps = require('gulp-sourcemaps');
var wait = require('gulp-wait');
var imagemin = require('gulp-imagemin');
var imagePngquant = require('imagemin-pngquant');
var imageRecompress = require('imagemin-jpeg-recompress');

var B_SCSS_PATH = 'node_modules/bootstrap/scss';
var B_JS_PATH = 'node_modules/bootstrap/dist/js';

var STYLE_PATH = 'public/css';
var JS_PATH = 'public/js';
var IMG_PATH = 'public/images';
var FONT_PATH = 'public/fonts';

gulp.task('styles', function(){
console.log('Starting style task');
return gulp.src('resources/scss/style.scss')
.pipe(wait(500))
.pipe(plumber(function(err){
console.log('Styles Task Error');
console.log(err);
this.emit('end');
}))
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(sourcemaps.write('.'))
.pipe(postcss([autoprefixer()])
//.pipe(minifycss())
.pipe(gulp.dest(STYLE_PATH))
.pipe(livereload());
});
gulp.task('scripts', function(){
console.log('Starting Script task');
return gulp.src('resources/js/**/*.js')
.pipe(plumber(function(err){
console.log('Styles Task Error');
console.log(err);
this.emit('end');
}))
.pipe(concat('main.js'))
//.pipe(uglify())
.pipe(gulp.dest(JS_PATH))
.pipe(livereload());
});
gulp.task('BootstrapStyle', function(){
console.log('Starting Bootstrap Style task');
return gulp.src(B_SCSS_PATH + '/bootstrap.scss')
.pipe(plumber(function(err){
console.log('Bootstrap Styles Task Error');
console.log(err);
this.emit('end');
}))
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(postcss([autoprefixer()])
.pipe(gulp.dest(STYLE_PATH))
.pipe(livereload());
});

gulp.task('BootstrapScripts', function(){
console.log('Starting Booststrap Script task');
return gulp.src(B_JS_PATH + '/bootstrap.js')
.pipe(plumber(function(err){
console.log('Styles Task Error');
console.log(err);
this.emit('end');
}))
.pipe(concat('bootstrap.js'))
//.pipe(uglify())
.pipe(gulp.dest(JS_PATH))
.pipe(livereload());
});
gulp.task('images',function(){
console.log('Starting Image compression task');
return gulp.src('resources/images/**/*.{png,jpg,jpeg,svg,gif}')
.pipe(imagemin(
[
imagemin.gifsicle(),
imagemin.jpegtran(),
imagemin.optipng(),
imagemin.svgo(),
imagePngquant(),
imageRecompress()
]
))
.pipe(gulp.dest(IMG_PATH))
});

gulp.task('default',
['styles','scripts','BootstrapStyle','BootstrapScripts','images'],
function(){
console.log('Default task running');
});


gulp.task('watch', ['default'], function(){
console.log('Watch task running');
require('./server.js');
livereload.listen();
gulp.watch('resources/scss/**/*.scss', ['styles']).on('change',
livereload.changed);
gulp.watch('resources/js/**/*.js', ['scripts']).on('change',
livereload.changed);
gulp.watch(B_SCSS_PATH + '/**/*.scss', ['BootstrapStyle']).on('change',
livereload.changed);
gulp.watch(B_JS_PATH + '/**/*.js', ['BootstrapScripts']).on('change',
livereload.changed);
gulp.watch(IMG_PATH, ['images']).on('change', livereload.changed);
gulp.watch('public/*.html').on('change', livereload.changed);
});

Gulp Error

最佳答案

我不知道为什么没有人回答我的问题。但我解决了我自己的问题。希望它能帮助别人。我已经卸载并安装了该 Node 并重新排序了 Gulp Style 任务,如下所示。

gulp.task('styles', function(){
console.log('Starting style task');
return gulp.src('resources/scss/style.scss')
.pipe(wait(500))
.pipe(plumber(function(err){
console.log('Styles Task Error');
console.log(err);
this.emit('end');
}))
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe( postcss([ autoprefixer()]) )
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(STYLE_PATH))
.pipe(livereload());
});

关于javascript - 运行 gulp 时出现类型错误。但找不到任何TypeError 是不是Node 和npm 版本有问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48353396/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com