admin管理员组文章数量:1432196
i am working with NodeJS and i am using gulp.
My foler look like that :
Root
dist
node_modules
src
index.html
gulpfile.js
package.json
My gulpfile is :
"use strict";
var gulp = require('gulp');
var connect = require('gulp-connect'); // runs a local dev server
var open = require('gulp-open'); // open a URL in a web browser
var config ={
port : 3000,
devBaseUrl : 'http://localhost',
paths:{
html:'./src/*.html',
dist:'./dist'
}
}
//Start a local development server
gulp.task = ('connect' , function(){
connect.server({
root:['dist'],
port: config.port,
base: config.devBaseUrl,
});
});
gulp.task('open', ['connect'], function(){
gulp.src('dist/index.html').pipe(open({uri: config.devBaseUrl + ":" + config.port + '/'}))
});
gulp.task('html',function(){
gulp.src(config.paths.html)
.pipe(gulp.dest(config.paths.dist))
.pipe(connect.reload());
});
gulp.task('default', ['html', 'open']);
When i am type 'gulp' in the cmd i get this error :
C:\Users\maor\Documents\NodeProject\2>gulp
[13:18:28] Using gulpfile ~\Documents\NodeProject\2\gulpfile.js
[13:18:28] Server started http://localhost:3000
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at Server._listen2 (net.js:1262:14)
at listen (net.js:1298:10)
at Server.listen (net.js:1394:5)
at ConnectApp.server (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:57:19)
at new ConnectApp (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:37:10)
at Object.server (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:170:12)
at Gulp.gulp.task (C:\Users\maor\Documents\NodeProject\2\gulpfile.js:18:10)
at Object.<anonymous> (C:\Users\maor\Documents\NodeProject\2\gulpfile.js:29:6)
I really dont know what the problem is , i already checked and the port : 3000 is free. can you guys help me figure what the problem is ?
i am working with NodeJS and i am using gulp.
My foler look like that :
Root
dist
node_modules
src
index.html
gulpfile.js
package.json
My gulpfile is :
"use strict";
var gulp = require('gulp');
var connect = require('gulp-connect'); // runs a local dev server
var open = require('gulp-open'); // open a URL in a web browser
var config ={
port : 3000,
devBaseUrl : 'http://localhost',
paths:{
html:'./src/*.html',
dist:'./dist'
}
}
//Start a local development server
gulp.task = ('connect' , function(){
connect.server({
root:['dist'],
port: config.port,
base: config.devBaseUrl,
});
});
gulp.task('open', ['connect'], function(){
gulp.src('dist/index.html').pipe(open({uri: config.devBaseUrl + ":" + config.port + '/'}))
});
gulp.task('html',function(){
gulp.src(config.paths.html)
.pipe(gulp.dest(config.paths.dist))
.pipe(connect.reload());
});
gulp.task('default', ['html', 'open']);
When i am type 'gulp' in the cmd i get this error :
C:\Users\maor\Documents\NodeProject\2>gulp
[13:18:28] Using gulpfile ~\Documents\NodeProject\2\gulpfile.js
[13:18:28] Server started http://localhost:3000
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at Server._listen2 (net.js:1262:14)
at listen (net.js:1298:10)
at Server.listen (net.js:1394:5)
at ConnectApp.server (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:57:19)
at new ConnectApp (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:37:10)
at Object.server (C:\Users\maor\Documents\NodeProject\2\node_modules\gulp-connect\index.js:170:12)
at Gulp.gulp.task (C:\Users\maor\Documents\NodeProject\2\gulpfile.js:18:10)
at Object.<anonymous> (C:\Users\maor\Documents\NodeProject\2\gulpfile.js:29:6)
I really dont know what the problem is , i already checked and the port : 3000 is free. can you guys help me figure what the problem is ?
Share Improve this question asked Mar 22, 2017 at 12:03 TalTal 2355 silver badges14 bronze badges3 Answers
Reset to default 7Are you running any other applications that might be using port 3000?
It's possible that a previous instance of node may still be running, even if you intended to kill it. Check your processes, I sometimes get this issue and generally use
killall node
to resolve it.
This problem arise, when node process already running on the port.
You can fix it by
pkill node
OR you can use this
killall node
you still see node process with this mand: ps aux | grep node.
If you are using windows, then open task manager & in process tab, search node & right click on that process & end process.
Surely it will work.
Or better still you can change the port number to something else like 8000.
本文标签: JavaScriptNodeJSgulpError listen EADDRINUSE 3000Stack Overflow
版权声明:本文标题:javascript - NodeJS , gulp , Error: listen EADDRINUSE :::3000 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740244767a2248034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论