webpack启动报错 Error: listen EADDRINUSE: address already in use 127.0.0.1:3000

启webpack报错信息:端口占用

F:\webpack4.x-react>npm run dev

> [email protected] dev F:\webpack4.x-react
> webpack-dev-server --open --port 3000 --hot --host 127.0.0.1

events.js:200
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
?[90m    at Server.setupListenHandle [as _listen2] (net.js:1306:16)?[39m
?[90m    at listenInCluster (net.js:1354:12)?[39m
?[90m    at doListen (net.js:1493:7)?[39m
?[90m    at processTicksAndRejections (internal/process/task_queues.js:82:21)?[39m
Emitted 'error' event on Server instance at:
?[90m    at emitErrorNT (net.js:1333:8)?[39m
?[90m    at processTicksAndRejections (internal/process/task_queues.js:81:21)?[39m {
  code: ?[32m'EADDRINUSE'?[39m,
  errno: ?[32m'EADDRINUSE'?[39m,
  syscall: ?[32m'listen'?[39m,
  address: ?[32m'127.0.0.1'?[39m,
  port: ?[33m3000?[39m
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `webpack-dev-server --open --port 3000 --hot --host 127.0.0.1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\software\node\node_cache\_logs\2020-03-05T07_33_56_540Z-debug.log

解决方法:

1.  在package.json文件中修改启动脚本换一个端口;

2. 在windows的cmd中kill掉占用3000端口的进程:

  • 打开cmd

  • 运行netstat -ano 找到进程号;

webpack启动报错 Error: listen EADDRINUSE: address already in use 127.0.0.1:3000_第1张图片

  • kill掉:

webpack启动报错 Error: listen EADDRINUSE: address already in use 127.0.0.1:3000_第2张图片

重启启动 npm run dev 后 OK;

你可能感兴趣的:(工具)