gulp命令显示错误

时间:2017-01-25 05:25:04

标签: node.js gulp

我正在尝试运行gulp命令以实现项目的自动化,但最终会出现错误。以下是我的gulp文件 -

gulpfile.js

var gulp = require('gulp'),
    webserver = require('gulp-webserver'),
    typescript = require('gulp-typescript'),
    sourcemaps = require('gulp-sourcemaps'),
    tscConfig = require('./tsconfig.json');

var appSrc = 'builds/development/',
    tsSrc = 'process/typescript/';

gulp.task('html', function() {
  gulp.src(appSrc + '**/*.html');
});

gulp.task('css', function() {
  gulp.src(appSrc + '**/*.css');
});

gulp.task('copylibs', function() {
  return gulp
    .src([
      'node_modules/es6-shim/es6-shim.min.js',
      'node_modules/systemjs/dist/system-polyfills.js',
      'node_modules/angular2/bundles/angular2-polyfills.js',
      'node_modules/systemjs/dist/system.src.js',
      'node_modules/rxjs/bundles/Rx.js',
      'node_modules/angular2/bundles/angular2.dev.js'
    ])
    .pipe(gulp.dest(appSrc + 'js/lib/angular2'));
});

gulp.task('typescript', function () {
  return gulp
    .src(tsSrc + '**/*.ts')
    .pipe(sourcemaps.init())
    .pipe(typescript(tscConfig.compilerOptions))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(appSrc + 'js/'));
});

gulp.task('watch', function() {
  gulp.watch(tsSrc + '**/*.ts', ['typescript']);
  gulp.watch(appSrc + 'css/*.css', ['css']);
  gulp.watch(appSrc + '**/*.html', ['html']);
});

gulp.task('webserver', function() {
  gulp.src(appSrc)
    .pipe(webserver({
      livereload: true,
      open: true
    }));
});

gulp.task('default', ['copylibs', 'typescript', 'watch', 'webserver']);

我已成功安装了npm install的所有依赖项。 这是我的package.json的样子 -

{
  "name": "AngularJS2",
  "version": "1.0.0",
  "author": "Sky",
  "description": "Angular2 Newbee",
  "repository": {
    "type": "git",
    "url": ""
  },
  "devDependencies": {
    "angular2": "2.0.0-beta.2",
    "systemjs": "0.19.6",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "zone.js": "0.5.10",
    "gulp": "^3.9.0",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-typescript": "^2.10.0",
    "gulp-webserver": "^0.9.1"
  }
}

我附上下面的错误,我开始运行gulp -

$ gulp
[10:44:11] Using gulpfile ~\desktop\angular2Ray\gulpfile.js
[10:44:11] Starting 'copylibs'...
[10:44:11] Starting 'typescript'...
[10:44:11] Starting 'watch'...
[10:44:11] Finished 'watch' after 31 ms
[10:44:11] Starting 'webserver'...
[10:44:11] Webserver started at http://localhost:8000
[10:44:11] Finished 'webserver' after 9.8 ms
internal/child_process.js:298
    throw errnoException(err, 'spawn');
    ^

Error: spawn UNKNOWN
    at exports._errnoException (util.js:870:11)
    at ChildProcess.spawn (internal/child_process.js:298:11)
    at exports.spawn (child_process.js:362:9)
    at Object.exports.execFile (child_process.js:151:15)
    at exports.exec (child_process.js:111:18)
    at open (C:\Users\user\desktop\angular2Ray\node_modules\open\lib\open.js:58:                                                            10)
    at Server.openInBrowser (C:\Users\user\desktop\angular2Ray\node_modules\gulp                                                            -webserver\src\index.js:100:5)
    at Server.g (events.js:260:16)
    at emitNone (events.js:67:13)
    at Server.emit (events.js:166:7)

任何人都可以帮我解决这个问题。任何帮助将非常感激。提前谢谢。

0 个答案:

没有答案