Gulp失败并返回Unhandled'错误'事件

时间:2015-06-08 18:21:17

标签: javascript node.js git coffeescript gulp

我正在运行Gulp并出现以下错误。

[14:16:00] Requiring external module coffee-script/register
[14:16:00] Using gulpfile ~/Documents/ion/game/Gulpfile.coffee
[14:16:00] Starting 'sass'...
[14:16:00] Starting 'coffee'...
[14:16:01] Starting 'templates'...

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn sass ENOENT
  at exports._errnoException (util.js:746:11)
  at Process.ChildProcess._handle.onexit (child_process.js:1046:32)
  at child_process.js:1137:20
  at process._tickCallback (node.js:355:11)

我的Gulpfile.coffee看起来像

gulp = require("gulp")
gutil = require("gulp-util")
concat = require("gulp-concat")
sass = require("gulp-ruby-sass")
minifyCss = require("gulp-minify-css")
rename = require("gulp-rename")
coffee = require("gulp-coffee")
sourcemaps = require("gulp-sourcemaps")
jade = require("gulp-jade")

paths =
  sass:
    source: ["styles/**/*.sass"]
    dest: './www/css'
  coffee:
    source: ["scripts/**/*.coffee"]
    dest: './www/js'
  templates:
    source: ["views/**/*.jade"]
    dest: './www'

gulp.task "default", ["sass", "coffee", "templates"]

gulp.task "templates", ->
  YOUR_LOCALS = {}

  gulp.src(paths.templates.source)
      .pipe(jade(locals: YOUR_LOCALS))
      .pipe(gulp.dest(paths.templates.dest))

gulp.task "coffee", (done) ->
  gulp.src(paths.coffee.source)
      .pipe(sourcemaps.init())
      .pipe(coffee(bare: true).on("error", gutil.log))
      .pipe(concat("application.js"))
      .pipe(sourcemaps.write())
      .pipe(gulp.dest(paths.coffee.dest))

gulp.task "sass", (done) ->
  gulp.src(paths.sass.source)
      .pipe(sass())
      .pipe(gulp.dest(paths.sass.dest))
      .pipe(minifyCss(keepSpecialComments: 0))
      .pipe(rename(extname: ".min.css"))
      .pipe(gulp.dest(paths.sass.dest))

gulp.task "watch", ->
  gulp.watch paths.sass.source, ->
    gulp.start("sass")
  gulp.watch paths.coffee.source, ->
    gulp.start("coffee")
  gulp.watch paths.templates.source, ->
    gulp.start("templates")

gulp.task 'install', ['git-check'], ->
  bower.commands.install()
    .on 'log', (data) ->
      gutil.log('bower', gutil.colors.cyan(data.id), data.message)

gulp.task 'git-check', (done) ->
  if !sh.which('git')
    console.log(
      '  ' + gutil.colors.red('Git is not installed.'),
      '\n  Git, the version control system, is required to download Ionic.',
      '\n  Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
      '\n  Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
    )
    process.exit(1)
  done()

我不知道导致错误的是什么,因为自从上次工作以来我在代码库中没有改变任何内容。任何帮助,将不胜感激。感谢。

1 个答案:

答案 0 :(得分:0)

ENOENT错误表示该文件不存在。仔细检查PATH中是否安装了sass个可执行文件。

如果一切正常,请删除SASS宝石并重新安装。

另外,但不相关,你可能想看看SASS的这个C ++实现,它提供了更快的编译https://github.com/sass/libsass