シンプルな gulpfile.js があります: シンプルな gulpfile.js があります: シンプルな gulpfile.js があります: シンプルな gulpfile.js があります: シンプルな gulpfile.js があります: シンプルな gulpfile.js があります:シンプルな gulpfile.js:シンプルな gulpfile.js があります
var gulp = require('gulp');
var less = require('gulp-less');
var nodemon = require('gulp-nodemon');
var watch = require('gulp-watch-less');
var path = require('path');
var bower = require('gulp-bower');
var livereload = require('gulp-livereload');
var connect = require('gulp-connect');
gulp.task('connect', function() {
connect.server({
root: ['./'],
port:8080,
livereload: true
});
});
gulp.task('less', function() {
// Code for the default task
return gulp.src('less/style.less')
.pipe(less())
.pipe(gulp.dest('stylesheets'))
});
gulp.task('watch',function(){
gulp.watch('less/**/*.less',['less']);
});
gulp.task('start', function () {
nodemon({
script: 'server.js'
, ext: 'js html'
, env: { 'NODE_ENV': 'development' }
})
})
gulp.task('default', ['start', 'watch','less','connect']);
サーバー.js
var http=require('http');
var express=require('express');
var jade=require('jade');
var app=express();
var chalk = require('chalk');
//var less = require('less');
//gestion des routes
var server=http.createServer(app);
var port = process.env.PORT || 8080;
app.set('view engine','jade');
app.use("/stylesheets",express.static(__dirname + "/stylesheets"));
app.use("/lib",express.static(__dirname + "/lib"));
app.use("/script",express.static(__dirname + "/script"));
app.use("/less",express.static(__dirname + "/less"));
app.use("/bower_components",express.static(__dirname + "/bower_components"));
app.use("/img",express.static(__dirname+"/img"));
app.use("/font",express.static(__dirname+"/font"));
app.use("/lib",express.static(__dirname+"/lib"));
app.get('/',function(req,res){
res.render('index');
});
アプリケーションを実行すると、このエラーが発生します。
**events.js:141
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::8080
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at Server._listen2 (net.js:1236:14)
at listen (net.js:1272:10)
at Server.listen (net.js:1368:5)
at Object.<anonymous> (C:\Users\achraf\Desktop\portfolio\server.js:52:8)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)**
コンソール
λ gulp
[22:35:56] Using gulpfile ~\Desktop\portfolio\Gulpfile.js
[22:35:56] Starting 'start'...
[22:35:56] Finished 'start' after 5.68 ms
[22:35:56] Starting 'watch'...
[22:35:56] Finished 'watch' after 35 ms
[22:35:56] Starting 'less'...
[22:35:56] Starting 'connect'...
[22:35:56] Finished 'connect' after 23 ms
[22:35:57] Server started https://localhost:8080
[22:35:57] LiveReload started on port 35729
[22:35:57] [nodemon] 1.8.1
[22:35:57] [nodemon] to restart at any time, enter `rs`
[22:35:57] [nodemon] watching: *.*
[22:35:57] [nodemon] starting `node server.js`
[22:35:57] Finished 'less' after 402 ms
[22:35:57] Starting 'default'...
[22:35:57] Finished 'default' after 25 μs
events.js:141
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::8080
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at Server._listen2 (net.js:1236:14)
at listen (net.js:1272:10)
at Server.listen (net.js:1368:5)
at Object.<anonymous> (C:\Users\achraf\Desktop\portfolio\server.js:52:8)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
[22:35:59] [nodemon] app crashed - waiting for file changes before starting...