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. docker绑定了nginx端口 外部访问不到2. javascript - 给某个类添加一个伪类,这个类有click事件,现在我点击伪类也触发了click事件3. angular.js - 怎样实现点击 “分数” 后按分数升序和降序排列?4. docker gitlab 如何git clone?5. 小白学python的问题 关于%d和%s的区别6. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?7. angular.js - angular内容过长展开收起效果8. javascript - 这是什么数组?9. javascript - npm run build后调用api返回index.html10. css - 如何更改 iOS 和安卓浏览器上的 input[type="radio"] 元素的默认样式?

网公网安备