2016-06-08 2 views
0

я получаю мою голову вокруг nodemon в данный момент пытается бежать с глотком:Как я могу запустить свой nodemon в моем угловом gulpprocess в то же время?

var gulp = require('gulp'), 
    connect = require('gulp-connect'); 

var nodemon = require('gulp-nodemon'); 

gulp.task('connect', function() { 
    connect.server({ 
    root: 'app', 
    livereload: true, 
    middleware: function(connect) { 
     return [connect().use('/bower_components', connect.static('bower_components'))]; 
    } 
    }); 
}); 

gulp.task('html', function() { 
    gulp.src('./app/**/*.html') 
    .pipe(connect.reload()); 
}); 

gulp.task('js', function() { 
    gulp.src('./app/**/*.js') 
    .pipe(connect.reload()); 
}); 

gulp.task('watch', function() { 
    gulp.watch(['./app/**/*.html'], ['html']); 
    gulp.watch(['./app/**/*.js'], ['js']); 
}); 

gulp.task('nodemon', function() { 
    nodemon({ script: 'quotes.js' 
     }) 
     .on('restart', function() { 
     console.log('restarted!') 
     }) 
    }) 

gulp.task('default', ['connect', 'watch','nodemon']); 

Угловая приложение работает отлично без nodemon, я просто хочу, чтобы запустить экспресс-сервер на тот же порт т.е. 8080:

var express = require('express'); 
var app = express(); 

var quotes = [ 
    { author : 'Audrey Hepburn', text : "Nothing is impossible, the word itself says 'I'm possible'!"}, 
    { author : 'Walt Disney', text : "You may not realize it when it happens, but a kick in the teeth may be the best thing in the world for you"}, 
    { author : 'Unknown', text : "Even the greatest was once a beginner. Don't be afraid to take that first step."}, 
    { author : 'Neale Donald Walsch', text : "You are afraid to die, and you're afraid to live. What a way to exist."} 
]; 

app.get('/quotes', function(req, res) { 
    res.json(quotes); 
}); 

app.listen(8080); 

console.log("The port is listening"); 

Однако я получаю эту ошибку сейчас, когда работает глотка:

Error: listen EADDRINUSE :::8080 
    at Object.exports._errnoException (util.js:896:11) 
    at exports._exceptionWithHostPort (util.js:919:20) 
    at Server._listen2 (net.js:1246:14) 
    at listen (net.js:1282:10) 
    at Server.listen (net.js:1378:5) 

GitHub: https://github.com/dimitri-a/grunt_yoyo.git

ответ

1

Эта ошибка означает, что порт 8080 уже используется. Попробуйте либо убить любые другие серверы, которые могли бы запущенные или изменение

app.listen(8080); 

к другому порту

app.listen(8081);