码迷,mamicode.com
首页 > 其他好文 > 详细

关于“Error: listen EADDRINUSE: address already in use 127.0.0.1:3000”

时间:2019-05-23 23:18:35      阅读:655      评论:0      收藏:0      [点我收藏+]

标签:error:   row   break   exp   put   bpa   vscode   bug   错误提示   

今天在做一个Vue小项目的时候,遇到了这样一个bug,终端输入npm run dev指令,本来按照我在package.json文件中配置的命令:"dev": "webpack-dev-server --open --port 3000 --hot",应该会运行webpack工具打包代码后,自动打开浏览器,监听3000端口,但是此时却在终端命令行提示出错,错误信息如下:

PS C:\Users\LXD\Desktop\my-vue\vue-cms> npm run dev

01.webpack-study@1.0.0 dev C:\Users\LXD\Desktop\my-vue\vue-cms
webpack-dev-server --open --port 3000 --hot

events.js:174
      throw er; // Unhandled ‘error‘ event
      ^

Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
    at Server.setupListenHandle [as listen2] (net.js:1253:19)
    at listenInCluster (net.js:1318:12)
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1451:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:61:10)
Emitted ‘error‘ event at:
    at emitErrorNT (net.js:1297:8)
    at process.
tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 01.webpack-study@1.0.0 dev: webpack-dev-server --open --port 3000 --hot
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 01.webpack-study@1.0.0 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!     C:\Users\LXD\AppData\Roaming\npm-cache_logs\2019-05-23T14_10_58_853Z-debug.log
PS C:\Users\LXD\Desktop\my-vue\vue-cms>

根据错误提示,Error: listen EADDRINUSE: address already in use 127.0.0.1:3000,意思是3000端口已经被占用。这时,我寻找的解决方案为:

  1. 打开cmd

  2. 运行netstat -ano,找到报错信息提示的端口号那一行,记住最后那个数字

技术图片技术图片

  3.接下来运行tskill “最后那个数字”,所以这里我运行的是tskill 8408

最后打开VSCode,在终端再次输入npm run dev,运行成功,问题解决。

关于“Error: listen EADDRINUSE: address already in use 127.0.0.1:3000”

标签:error:   row   break   exp   put   bpa   vscode   bug   错误提示   

原文地址:https://www.cnblogs.com/smalldy/p/10915046.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!