ReferenceError를 던지는 Gulp-autoprefixer : Promise가 정의되지 않았습니다.
나는 내 sass를 컴파일 한 다음 autoprefixit을 사용하여 꿀꺽 꿀꺽 마시려고 노력 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를 사용할 때 작동하지 않습니다. 내 파일에 뭔가가 있다고 생각합니다.
같은 문제가있었습니다. 나를 위해 노드 업데이트가 작동하지 않았지만 gulpfile의 맨 처음에 이것을 추가하면 다음과 같이 작동했습니다.
require('es6-promise').polyfill();
다음을 사용하여 node.js를 최신 버전으로 업데이트했습니다.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
여기에 표시된대로 내 Ubuntu 컴퓨터의 경우 .
그 후 다음을 사용하여 NPM을 업데이트했습니다.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
여기에 표시된대로 .
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.
Install es6-promise in ur project location where package.json exists
npm install es6-promise
Then make the first line of your gulpfile.js be the following code:
var Promise = require('es6-promise').Promise;
This does not answer the question directly but it might be useful for people that get this error when trying to run the ionic 2 tutorial.
As pointed by other answers the problem is that es6-promise
is missing.
I got the same error when trying to start the ionic 2 tutorial (https://github.com/driftyco/ionic2-starter-tutorial): (my ionic 2 version is 2.0.0-beta.25 and latest tutorial commit is ed9ef2fcce887e4d1c08c375c849b06b8394bad7)
This is the stack trace I got when trying to run the app with ionic serve
:
Running 'serve:before' gulp task before serve
[18:37:00] Starting 'clean'...
[18:37:01] Finished 'clean' after 1.02 s
[18:37:01] Starting 'watch'...
[18:37:01] Starting 'sass'...
[18:37:01] Starting 'html'...
[18:37:01] Starting 'fonts'...
[18:37:01] Starting 'scripts'...
[18:37:01] Finished 'scripts' after 62 ms
[18:37:01] Finished 'html' after 72 ms
[18:37:01] Finished 'fonts' after 77 ms
Caught exception:
ReferenceError: Promise is not defined
at LazyResult.async (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:157:31)
at LazyResult.then (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-autoprefixer/node_modules/postcss/lib/lazy-result.js:79:21)
at DestroyableTransform._transform (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-autoprefixer/index.js:24:6)
at DestroyableTransform.Transform._read (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83)
at doWrite (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:313:64)
at writeOrBuffer (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:241:11)
at DestroyableTransform.ondata (/home/stitakis/dev/playground/ionic2/myTutorial/node_modules/ionic-gulp-sass-build/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:531:20)
at DestroyableTransform.EventEmitter.emit (events.js:95:17)
Again, as pointed by other answers, this is how to solve this:
edit gulpfile.js and add in line 6:
require('es6-promise').polyfill();
install the missing dependency with:
npm install es6-promise --save
After this changes, the problem was fixed and I was able to start the local server.
'Development Tip' 카테고리의 다른 글
파이썬에서 문자열을 바이너리로 변환 (0) | 2020.10.04 |
---|---|
Spyder / IPython / matplotlib에서 대화 형 플롯을 다시 얻으려면 어떻게해야합니까? (0) | 2020.10.04 |
Node.js에서 path.normalize와 path.resolve의 차이점 (0) | 2020.10.04 |
Symfony 2 양식 요소에 오류 추가 (0) | 2020.10.04 |
405 메서드가 허용되지 않는 웹 API (0) | 2020.10.04 |