Gulp-autoprefixer引发ReferenceError:Promise未定义 [英] Gulp-autoprefixer throwing ReferenceError: Promise is not defined
问题描述
我尝试使用gopp编译我的sass,然后使用 gulp-autoprefixer
autoprefixit,但是我收到了一个错误消息。
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测试
我得到这个:
/ 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未定义
LazyResult.async(/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:152:31)
LazyResult.then( /home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:75:21)
在DestroyableTransform._transform(/ home / matei / Tests / test -4 / node_modules /咽-autoprefixer /索引.js:28:13)
在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)
在doWrite(/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:326:12)
在destroyableTransform.Writable上的writeOrBuffer(/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:312:5)
。写入(/home/matei/Tests/test-4/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:239:11)
写入(/ home / matei /测试/检验-4 / node_modules /咽-SASS / node_modules / through2 / node_m (/ home / matei / Tests / test-4 / node_modules / gulp-sass / node_modules / through2 / node_modules /可读流/可读流/ lib / _stream_readable.js:623:24) lib / _stream_readable.js:632:7)
我真的不知道我在做什么错误。当我使用sass或普通的css时不工作。我认为是与我的文件。
我更新node.js到最新版本使用:
#使用Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x |对于我的Ubuntu机器,sudo -E bash -
sudo apt-get install -y nodejs
,如此处所示。
之后我使用以下方式更新了NPM:
sudo npm cache clean -f $ b $ sudo npm install -gn
sudo n stable
如图所示这里。
现在 gulp-autoprefixer
开始工作,但我从 gulp-sass
发生错误。我使用以下指令更新了它:
- 删除您的node_modules文件夹
- 删除您的gulp-sass package.json文件
- 从你的package.json文件中删除node-sass(如果你有它)
- 运行npm install gulp-sass --save-dev
- 根据需要更新您的Gulp任务
找到这里。现在我有 gulp-sass:^ 2.0.4
并且解决了我所有的问题。
感谢您的建议和帮助。 >
I try to make a gulp compile my sass then autoprefixit with gulp-autoprefixer
but i'm getting an error.
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'));
});
I'm trying to run this Gulpfile.js
and i'm using :
"gulp": "~3.9.0",
"gulp-sass": "~2.0.4",
"gulp-autoprefixer": "~3.0.1",
and NPM version 1.3.10
When i run gulp test
i get this :
/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)
I don't really know what i'm doing wrong. Is not working when i use sass or plain css. I think is something with my files.
I updated node.js to the latest version using :
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
for my Ubuntu machine, as shown here.
After that i updated NPM using :
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
As shown here.
Now the gulp-autoprefixer
start working but i got an error from gulp-sass
. I updated it using this instruction :
- Delete your node_modules folder
- Remove gulp-sass from your package.json file
- Remove node-sass from your package.json file (if you have it in there)
- Run npm install gulp-sass --save-dev
- Update your Gulp task as required
Found here.Now i have "gulp-sass": "^2.0.4"
and this fixed all my problems.
Thanks for advice and help.
这篇关于Gulp-autoprefixer引发ReferenceError:Promise未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!