schickling / gulp-webserver

Streaming gulp plugin to run a local webserver with LiveReload
https://www.npmjs.org/package/gulp-webserver
MIT License
355 stars 84 forks source link

gulp command shows error on gitbash #119

Open ATakaSKY opened 7 years ago

ATakaSKY commented 7 years ago

I am trying to run gulp command on gibash to start the project but its showing an error:

$ gulp
[01:11:49] Using gulpfile ~\desktop\ang2form\angular2-reactive-forms-data-and-validation\gulpfile.js
[01:11:49] Starting 'default'...
[01:11:49] Starting 'clean'...
[01:11:51] Finished 'clean' after 2.16 s
[01:11:51] Starting 'build'...
[01:11:51] Starting 'clean'...
[01:11:51] Finished 'clean' after 1.71 ms
[01:11:51] Starting 'copylibs'...
[01:11:51] Starting 'copystatic'...
[01:11:51] Starting 'typescript'...
[01:12:01] Finished 'copystatic' after 10 s
[01:12:02] Finished 'typescript' after 11 s
[01:12:18] Finished 'copylibs' after 27 s
[01:12:18] Finished 'build' after 27 s
[01:12:18] Starting 'watch'...
[01:12:18] Finished 'watch' after 66 ms
[01:12:18] Starting 'webserver'...
[01:12:18] Webserver started at http://localhost:8000
[01:12:18] Finished 'webserver' after 11 ms
[01:12:18] Finished 'default' after 29 s
internal/child_process.js:313
    throw errnoException(err, 'spawn');
    ^

Error: spawn UNKNOWN
    at exports._errnoException (util.js:1022:11)
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at exports.spawn (child_process.js:380:9)
    at Object.exports.execFile (child_process.js:143:15)
    at exports.exec (child_process.js:103:18)
    at open (C:\Users\user\desktop\ang2form\angular2-reactive-forms-data-and-validation\node_modules\gulp-webserver\node_modules\open\lib\open.js:58:10)
    at Server.openInBrowser (C:\Users\user\desktop\ang2form\angular2-reactive-forms-data-and-validation\node_modules\gulp-webserver\src\index.js:100:5)
    at Server.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at Server.emit (events.js:185:7)

Here's my gulpfile:

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

var appSrc = './dist/';
var tsProject = typescript.createProject('tsconfig.json');

gulp.task('build', function (callback) {
  runSequence('clean', ['copylibs', 'copystatic', 'typescript'], callback);
});

gulp.task('clean', function () {
  return del(appSrc);
});

gulp.task('copylibs', function () {
  return gulp
    .src([
      'node_modules/systemjs/dist/system-polyfills.js',
      'node_modules/systemjs/dist/system.src.js',
      'node_modules/zone.js/dist/*.js',
      'node_modules/core-js/**/*.js',
      'node_modules/reflect-metadata/*.js',
      'node_modules/rxjs/**/*.js',
      'node_modules/@angular/**/*.js'
    ], { base: 'node_modules' })
    .pipe(gulp.dest(appSrc + 'vendor'));
});

gulp.task('typescript', function () {
  return gulp
    .src(['src/**/*.ts'])
    .pipe(sourcemaps.init())
    .pipe(tsProject())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(appSrc));
});

var staticFiles = [
  'src/**/*.html',
  'src/**/*.css',
  'src/**/*.ico',
  'src/**/*.png',
  'src/**/*.svg',
  'src/**/*.jpg',
  'src/**/*.ttf',
  'src/**/*.woff2',
  'src/**/*.webapp',
  'src/systemjs.config.js'
];
gulp.task('copystatic', function () {
  return gulp
    .src(staticFiles)
    .pipe(gulp.dest(appSrc));
});

gulp.task('watch', function () {
  gulp.watch('src/**/*.ts', ['typescript']);
  gulp.watch(staticFiles, ['copystatic']);
});

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

gulp.task('default', function (callback) {
  runSequence('clean', 'build', ['watch', 'webserver'], callback);
});

I posted on SO as well but didn't receive a healthy response. Can anyone give a clue as to what is wrong here?