2014-05-08 69 views
3

我的目標是創建一組文件和包,以便在我的團隊中輕鬆共享。目前我在本地Mac 10.9.2上安裝了GulpJs,並且編譯正確。然而,當我跟我的兩個同事分享我的設置,以及它們運行的​​一飲而盡命令有錯誤:Gulp Error Spawn EN0ENT

events.js:72 
     throw er; // Unhandled 'error' event 
      ^
Error: spawn ENOENT 
    at errnoException (child_process.js:998:11) 
    at Process.ChildProcess._handle.onexit (child_process.js:789:34) 

後續是我的package.json文件:

{ 
    "name": "MyApp", 
    "version": "0.0.1", 
    "description": "Name build process for responsive development frameworks", 
    "author": "My Name", 
    "devDependencies": { 
    "gulp-util": "^2.2.14", 
    "gulp": "^3.6.2", 
    "gulp-compass": "^1.1.8", 
    "gulp-concat": "^2.2.0", 
    "gulp-uglify": "^0.2.1", 
    "gulp-livereload": "^1.2.0", 
    "tiny-lr": "0.0.5", 
    "gulp-jshint": "^1.5.3", 
    "gulp-minify-html": "^0.1.1", 
    "gulp-minify-css": "^0.3.0", 
    "image-min": "^0.4.5", 
    "gulp-imagemin": "^0.5.0", 
    "gulp-newer": "^0.3.0" 
    } 
} 

然後,我有我的gulpfile.js設置爲這樣:

// include gulp 
var gulp = require('gulp'), 
    gutil = require('gulp-util'); 

// include plug-ins 
var compass = require('gulp-compass'), 
    jshint = require('gulp-jshint'), 
    imagemin = require('gulp-imagemin'), 
    newer = require('gulp-newer'), 
    minifyHTML = require('gulp-minify-html'), 
    minifyCSS = require('gulp-minify-css'), 
    concat = require('gulp-concat'), 
    uglify = require('gulp-uglify'), 
    reload = require('gulp-livereload'), 
    lr = require('tiny-lr'), 
    server = lr(); 



var paths = { 
    jsSrc: [ 
     './src/js/vendor/jquery.js', 
     './src/js/vendor/fastclick.js', 
     './src/js/vendor/foundation.js' 
    ], 
    ieJsSrc: [ 
     './src/js/vendor/foundation-ie/jquery.js', 
     './src/js/vendor/foundation-ie/jquery.foundation.buttons.js', 
     './src/js/vendor/foundation-ie/jquery.foundation.clearing.js', 
     './src/js/vendor/foundation-ie/jquery.foundation.forms.js', 
     './src/js/vendor/foundation-ie/jquery.foundation.reveal.js', 
     './src/js/vendor/foundation-ie/jquery.foundation.tabs.js', 
     './src/js/vendor/foundation-ie/jquery.foundation.tooltips.js' 
    ], 
    jsDst: './src/js', 
    jsBuild: './build/common/js', 
    imgSrc: './src/img/*', 
    imgDst: './build/common/img', 
    imgBgSrc: './src/img/bg/*', 
    imgPhotoSrc: './src/img/photos/*', 
    imgBgDst: './build/common/img/bg', 
    imgPhotoDst: './build/common/img/photos', 
    htmlSrc: './src/**/*.html', 
    htmlDst: './build', 
    scssSrc: [ 
      './src/_scss/utsw.scss', 
      './src/_scss/utsw-ie.scss', 
      './src/_scss/themes/**/*.scss' 
    ], 
    scssDst: './src/common/css/', 
    cssMedSrc: './src/css/themes/root/*.css', 
    cssMedDst: './src/root/css/', 
    cssMedBuild: './build/root/css/', 
    cssEaSrc: './src/css/themes/sites/early-access/*.css', 
    cssEaDst: './src/sites/early-access/css', 
    cssEaBuild: './build/sites/early-access/css', 
    cssProSrc: './src/css/themes/profile/*.css', 
    cssProDst: './src/profile/css/', 
    cssProBuild: './build/profile/css/', 
    cssNetSrc: './src/css/themes/intranet/*.css', 
    cssNetDst: './src/intranet/css/', 
    cssNetBuild: './build/intranet/css/' 
}; 

// JS hint task 
gulp.task('jshint', function() { 
    return gulp.src(paths.jsSrc) 
    .pipe(jshint()) 
    .pipe(jshint.reporter('default')); 
}); 

// minify new or changed HTML pages 
gulp.task('html', function() { 

    return gulp.src(paths.htmlSrc) 
    .pipe(gulp.dest(paths.htmlDst)); 
}); 

// JS concat, strip debugging and minify 
gulp.task('scripts', function() { 
    return gulp.src(paths.jsSrc) 
    .pipe(concat('vendor.min.js')) 
    .pipe(gulp.dest(paths.jsDst)) 
    .pipe(uglify()) 
    .pipe(gulp.dest(paths.jsBuild)); 
}); 

gulp.task('ieScripts', function() { 
    return gulp.src(paths.ieJsSrc) 
    .pipe(concat('ie-vendor.min.js')) 
    .pipe(gulp.dest(paths.jsDst)) 
    .pipe(uglify()) 
    .pipe(gulp.dest(paths.jsBuild)); 
}); 

// Minify any new images 
gulp.task('images', function() { 
    return gulp.src(paths.imgSrc) 
     .pipe(newer(paths.imgDst)) 
     .pipe(imagemin({optimizationLevel: 5})) 
     .pipe(gulp.dest(paths.imgDst)); 
}); 

// Minify any new images 
gulp.task('bg', function() { 
    // Add the newer pipe to pass through newer images only 
    return gulp.src(paths.imgBgSrc) 
     .pipe(newer(paths.imgBgDst)) 
     .pipe(imagemin({optimizationLevel: 5})) 
     .pipe(gulp.dest(paths.imgBgDst)); 
}); 

// Minify any new images 
gulp.task('photos', function() { 
    // Add the newer pipe to pass through newer images only 
    return gulp.src(paths.imgPhotoSrc) 
     .pipe(newer(paths.imgPhotoDst)) 
     .pipe(imagemin({optimizationLevel: 5})) 
     .pipe(gulp.dest(paths.imgPhotoDst)); 
}); 

gulp.task('compass', function() { 
    return gulp.src(paths.scssSrc) 
     .pipe(compass({ 
      sass: './src/_scss', 
      css: './src/css', 
      image: './src/img' 
     })) 
     .on('error', function(err) { 
      // Would like to catch the error here 
     }) 
     .pipe(gulp.dest('./src/temp')); 
}); 

gulp.task('rootCSS', function() { 
    return gulp.src(paths.cssMedSrc) 
    .pipe(gulp.dest(paths.cssMedDst)) 
    .pipe(minifyCSS()) 
    .pipe(gulp.dest(paths.cssMedBuild)); 
}); 

gulp.task('eaCSS', function() { 
    return gulp.src(paths.cssEaSrc) 
    .pipe(gulp.dest(paths.cssEaDst)) 
    .pipe(minifyCSS()) 
    .pipe(gulp.dest(paths.cssEaBuild)); 
}); 

gulp.task('proCSS', function() { 
    return gulp.src(paths.cssProSrc) 
    .pipe(gulp.dest(paths.cssProDst)) 
    .pipe(minifyCSS()) 
    .pipe(gulp.dest(paths.cssProBuild)); 
}); 

gulp.task('netCSS', function() { 
    return gulp.src(paths.cssNetSrc) 
    .pipe(gulp.dest(paths.cssNetDst)) 
    .pipe(minifyCSS()) 
    .pipe(gulp.dest(paths.cssNetBuild)); 
}); 

// Rerun the task when a file changes 
gulp.task('watch', function() { 
    var server = reload(); 
    gulp.watch(paths.htmlSrc, ['html']); 
    gulp.watch(paths.jsSrc, ['scripts']); 
    gulp.watch(paths.ieJsSrc, ['ieScripts']); 
    gulp.watch(paths.imgSrc, ['images']); 
    gulp.watch(paths.imgBgSrc, ['bg']); 
    gulp.watch(paths.imgPhotoSrc, ['photos']); 
    gulp.watch(paths.scssSrc, ['compass']); 
    gulp.watch(paths.cssMedSrc, ['rootCSS']); 
    gulp.watch(paths.cssEaSrc, ['eaCSS']); 
    gulp.watch(paths.cssProSrc, ['proCSS']); 
    gulp.watch(paths.cssNetSrc, ['netCSS']); 
    gulp.watch(['./src/*.html', './src/js/', './src/css/*.css'], function(e) { 
     server.changed(e.path); 
    }); 
}); 

// The default task (called when you run `gulp` from cli) 
gulp.task('default', [ 
    'html', 
    'scripts', 
    'ieScripts', 
    'images', 
    'bg', 
    'photos', 
    'compass', 
    'rootCSS', 
    'eaCSS', 
    'proCSS', 
    'netCSS', 
    'watch' 
]); 

如何使用相同的SRC讓我的同事建立和gulpfile.js將是真棒任何建議。

+0

他們是否安裝了相同版本的所有版本,包括Node,gulp(全局和本地)以及所有版本?嘗試在你的機器上運行'npm update -g'和'npm update',也許他們有更新的版本。 – OverZealous

+0

這可能是一次運行多個任務。確保你按照正確的順序定義了任務,並且如果你有異步任務,確保使用orchestrator的回調系統 – Markasoftware

+0

同樣的事情發生在我身上,但是同樣的腳本在mac中工作,但是它會拋出同樣的錯誤窗戶,不明白爲什麼它發生在我身上。 –

回答

-3

試着再次刪除並安裝imagemin和gulp-imagemin。

相關問題