gulp的gulp-ruby-sass插件啟動不了報錯!
問題描述
報錯:
λ gulp serve[18:22:40] Working directory changed to F:new-gulp-test[18:22:41] Using gulpfile F:new-gulp-testgulpfile.js[18:22:41] Starting ’scss’...[18:22:41] ’scss’ errored after 7.01 ms[18:22:41] ReferenceError: scss is not defined at Gulp.<anonymous> (F:new-gulp-testgulpfile.js:58:15) at module.exports (F:new-gulp-testnode_modules.npminstallorchestrator0.3.7orchestratorlibrunTask.js:34:7) at Gulp.Orchestrator._runTask (F:new-gulp-testnode_modules.npminstallorchestrator0.3.7orchestratorindex.js:273:3) at Gulp.Orchestrator._runStep (F:new-gulp-testnode_modules.npminstallorchestrator0.3.7orchestratorindex.js:214:10) at Gulp.Orchestrator.start (F:new-gulp-testnode_modules.npminstallorchestrator0.3.7orchestratorindex.js:134:8) at C:UsersAdministratorAppDataRoamingnpmnode_modules.gulp_npminstallgulp3.9.1gulpbingulp.js:129:20 at nextTickCallbackWith0Args (node.js:420:9) at process._tickCallback (node.js:349:13) at Function.Module.runMain (module.js:443:11) at startup (node.js:139:18)
node_modules目錄
gulpfile.js配置
var minifycss = require(’gulp-minify-css’),// CSS壓縮 uglify = require(’gulp-uglify’),// js壓縮 concat = require(’gulp-concat’),// 合并文件 rename = require(’gulp-rename’),// 重命名 clean = require(’gulp-clean’);//清空文件夾var gulp = require(’gulp’), sass = require(’gulp-ruby-sass’); notify = require(’gulp-notify’), plumber = require(’gulp-plumber’); browserSync = require(’browser-sync’).create(), reload = browserSync.reload;gulp.task(’serve’, [’scss’], function() { browserSync.init({server: './stc' }); gulp.watch('stc/**/*.scss', [’scss’]); gulp.watch('stc/*.html').on(’change’, reload);});gulp.task(’scss’, function() { return gulp.src([’stc/scss/*.scss’,’!stc/scss/extend/{reset,test}.scss’]).pipe(plumber({errorHandler: notify.onError(’Error: <%= error.message %>’)})).pipe(scss()).pipe(gulp.dest('stc/css')).pipe(reload({stream: true}));});gulp.task(’default’, [’serve’]);
問題解答
回答1:你沒有一個叫scss的變量,看這里:
gulp.task(’scss’, function() { return gulp.src([’stc/scss/*.scss’,’!stc/scss/extend/{reset,test}.scss’]).pipe(plumber({errorHandler: notify.onError(’Error: <%= error.message %>’)})).pipe(sass()) //這里不對,應該是sass吧 .pipe(gulp.dest('stc/css')).pipe(reload({stream: true}));});回答2:
ruby-sass 是依賴 ruby 的,你確定 ruby 環境無誤么?建議還是直接用 node-sass 性能也更好一些。
相關文章:
1. centos - apache配置django報錯:cannot be loaded as Python modules2. 微信端電子書翻頁效果3. node.js - 有沒有比較好的nodejs導出excel的插件?4. css3 - 微信前端頁面遇到的transition過渡動畫的bug5. mysql - SQL問個基礎例子,書上的,我怎么看都看不懂..誰幫我解釋一下第2個為什么和第1個一樣?6. javascript - 微信小程序里怎么把頁面轉成圖片分享7. mysql事務日志的一些問題8. mysql服務無法啟動1067錯誤,誰知道正確的解決方法?9. mysql - 我用SQL語句 更新 行的時候,發現全部 中文都被清空了,請問怎么解決?10. 數據庫 - mysql boolean型無法插入true
