L
L
lazuren2015-09-30 12:36:14
gulp.js
lazuren, 2015-09-30 12:36:14

How to fix Unhandled 'error' event when running Gulp?

When running Gulp, it throws the following error:

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: listen EACCES
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1139:19)
    at listen (net.js:1182:10)
    at net.js:1280:9
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:81:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:99:10)

I installed gulp-plumber, but it doesn't help me, or I didn't do something right. Here is the gulpfile.js file:
global.hostname = "localhost";

var gulp = require('gulp'),
plumber = require('gulp-plumber'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename');

gulp.task('express', function() {
  var express = require('express');
  var app = express();
  app.use(require('connect-livereload')({port: 35729}));
  app.use(express.static(__dirname + '/app'));
  app.listen('80', hostname);
});

var tinylr;
gulp.task('livereload', function() {
  tinylr = require('tiny-lr')();
  tinylr.listen(35729);
});

function notifyLiveReload(event) {
  var fileName = require('path').relative(__dirname, event.path);
  tinylr.changed({
    body: {
      files: [fileName]
    }
  });
}

gulp.task('styles', function () {
  gulp.src('sass/*.sass')
  .pipe(plumber())
  .pipe(sass({
    includePaths: require('node-bourbon').includePaths
  }).on('error', sass.logError))
  .pipe(rename({suffix: '.min', prefix : '_'}))
  .pipe(autoprefixer({
    browsers: ['last 15 versions'],
    cascade: false
  }))
  .pipe(minifycss())
  .pipe(gulp.dest('app'));
});

gulp.task('watch', function() {
  gulp.watch('sass/*.sass', ['styles']);
  gulp.watch('app/*.css', notifyLiveReload);
  gulp.watch('app/*.html', notifyLiveReload);
});

gulp.task('default', ['styles', 'express', 'livereload', 'watch'], function() {

});

Tell me who knows what the problem is here.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aves, 2015-09-30
@lazuren

Written by EACCES, denied access, apparently not enough rights toapp.listen('80', hostname);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question