我在试着用自动修复器,sass和肝脏来运行一个吞咽文件。我花了整个晚上,但我不能运行他们,它到处都是T。
有人能给一个教程或吞咽文件安装这些插件吗?
非常感谢你
gulpfile.js
'use strict';
var gulp = require('gulp'),
sass = require('gulp-sass'),
livereload = require('gulp-livereload'),
autoprefixer = require('gulp-autoprefixer');
gulp.task('sass', function () {
gulp.src('public_html/style/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('css'))
.pipe(livereload());
});
gulp.task('watch', function () {
livereload.listen(35729);
gulp.watch('public_html/style/scss/**/*.scss', ['sass']);
});来自终端的错误日志:
[22:46:02] Using gulpfile /var/www/satbalma/Gulpfile.js
[22:46:02] Starting 'watch'...
[22:46:03] Finished 'watch' after 357 ms
[22:48:43] Starting 'sass'...
[22:48:43] Finished 'sass' after 22 ms
/var/www/satbalma/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:157
this.processing = new Promise(function (resolve, reject) {
^
ReferenceError: Promise is not defined
at LazyResult.async (/var/www/satbalma/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:157:31)
at LazyResult.then (/var/www/satbalma/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:79:21)
at DestroyableTransform._transform (/var/www/satbalma/node_modules/gulp-autoprefixer/index.js:24:6)
at DestroyableTransform.Transform._read (/var/www/satbalma/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (/var/www/satbalma/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83)
at doWrite (/var/www/satbalma/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:313:64)
at writeOrBuffer (/var/www/satbalma/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (/var/www/satbalma/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:241:11)
at DestroyableTransform.ondata (/var/www/satbalma/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:531:20)
at DestroyableTransform.emit (events.js:95:17)发布于 2016-04-08 20:59:09
我以前也犯过这个错误。将以下内容添加到package.json中
"es6-promise": "~3.1.2",
"es6-promise-polyfill": "~1.2.0",在你的gulpfile.js中:
var Promise = require('es6-promise').Promise;应该会有帮助
发布于 2016-04-08 21:06:31
您可以将普通autoprefixer与gulp-postcss一起使用,如下所示:
npm i --save-dev gulp-postcss autoprefixergulpfile.js
'use strict';
var gulp = require('gulp'),
sass = require('gulp-sass'),
livereload = require('gulp-livereload'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer')({ browsers: ['last 2 versions'] });
gulp.task('sass', function () {
gulp.src('public_html/style/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss([autoprefixer]))
.pipe(gulp.dest('css'))
.pipe(livereload());
});
gulp.task('watch', function () {
livereload.listen(35729);
gulp.watch('public_html/style/scss/**/*.scss', ['sass']);
});https://stackoverflow.com/questions/36508380
复制相似问题