我第一次在 Windows Server 2012 VM 上尝试 gulp。我通常是 Mac 用户,所以对于像这样的开发工具,我对 Windows 和 Powershell 有点陌生。我安装了 Node.js & npm(没有别的)。我创建了以下基本 Gulpfile 来编译我的 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']);
在 Windows Powershell 中,我运行 gulp
命令,它输出以下内容:
[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
我是不是漏掉了什么?我需要安装 Ruby 还是 Sass?我想这样做,我需要一个 Ruby 命令提示符,而 PowerShell 无法访问它。任何指导表示赞赏!
最佳答案
是的,没错,您需要安装 Ruby
和 Sass
才能使 gulp-ruby-sass
正常工作。
首先根据您的规范在 this address 下载 Ruby
安装程序.安装后,您应该将它安装在您的系统上,并可通过 PowerShell
或简单的命令行访问。
之后,运行命令即可
gem install sass
大功告成。
关于windows - gulp-ruby-sass 在 Windows 中不是可识别的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24937506/