问题
I'm trying out gulp for the first time on a Windows Server 2012 VM. I'm normally a Mac user, so I'm a bit new to Windows & Powershell for dev tools like this. I installed Node.js & npm (and nothing else). I created the following basic Gulpfile to compile my Sass:
Gulpfile.js
var gulp = require('gulp'),
sass = require('gulp-ruby-sass');
gulp.task('styles', function() {
return gulp.src('Content/sass_new/application.scss')
.pipe(sass({ style: 'expanded', }))
.pipe(gulp.dest('Content/css'))
});
gulp.task('watch', function() {
gulp.watch('Content/sass_new/*', ['styles']);
})
gulp.task('default', ['styles']);
In Windows Powershell, I run the gulp
command, and it outputs the following:
[10:02:57] Using gulpfile C:\[path to]\gulpfile.js
[10:02:57] Starting 'styles'...
[10:02:57] gulp-ruby-sass: 'sass' is not recognized as an internal or external command,
operable program or batch file.
[10:02:57] Finished 'styles' after 316 ms
[10:02:57] Starting 'default'...
[10:02:57] Finished 'default' after 15 μs
Am I missing something here? Do I need to install Ruby or Sass? I thought to do that, I'd need a Ruby command prompt and PowerShell wouldn't have access to it. Any guidance is appreciated!
回答1:
Yes that's right, you need to install Ruby
and Sass
to get gulp-ruby-sass
working.
Begin by download the Ruby
installer depending on your specs at this address. Once installed you supposed to have it on your system and accessible by PowerShell
or the simple command line.
After, just run the command
gem install sass
And you're done.
回答2:
Download and Install Ruby : http://rubyinstaller.org/
set ruby location to Path Environment Variable
restart the command prompt
and run gem install sass
That's it.
来源:https://stackoverflow.com/questions/24937506/gulp-ruby-sass-not-a-recognized-command-in-windows