我试着让我的sass编译一下,然后用gulp-autoprefixer自动修复,但是我得到了一个错误。
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer');
gulp.task('test', function(){
gulp.src('_sass/main.sass')
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulp.dest('./assets/css'));
});我正在尝试运行这个Gulpfile.js,我正在使用:
"gulp": "~3.9.0",
"gulp-sass": "~2.0.4",
"gulp-autoprefixer": "~3.0.1",和NPM版本1.3.10
当我运行gulp test时,我得到这样的结果:
/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:152
this.processing = new Promise(function (resolve, reject) {
^
ReferenceError: Promise is not defined
at LazyResult.async (/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:152:31)
at LazyResult.then (/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:75:21)
at DestroyableTransform._transform (/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/index.js:28:13)
at DestroyableTransform.Transform._read (/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:10)
at DestroyableTransform.Transform._write (/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:160:12)
at doWrite (/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:326:12)
at writeOrBuffer (/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:312:5)
at DestroyableTransform.Writable.write (/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:239:11)
at write (/home/matei/Tests/test-4/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/matei/Tests/test-4/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)我真的不知道我做错了什么。当我使用sass或纯css时不起作用。我想是我的档案有问题。
发布于 2015-10-05 09:31:55
也有同样的问题。对我来说,更新node不起作用,但在我的gulpfile的最开始添加以下命令:
require('es6-promise').polyfill();发布于 2016-02-06 01:14:31
在package.json所在的项目位置安装es6-promise
npm install es6-promise然后,将gulpfile.js的第一行代码设置为以下代码:
var Promise = require('es6-promise').Promise;https://stackoverflow.com/questions/32490328
复制相似问题