windows系统中端口被占用时的处理方法(Vue项目为例)

背景:最近在用Vue做项目,早上就把项目跑起来开始开发,中午休息没有管,下午再开发时发现修改的东西不起效,好吧,重新运行下项目,结果报错如下一堆:

$ npm run dev

> monkey-tell@1.0.0 dev F:\webstorm\****
> node build/dev-server.js

> Starting dev server...
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::8732
    at Object.exports._errnoException (util.js:1020:11)
    at exports._exceptionWithHostPort (util.js:1043:20)
    at Server._listen2 (net.js:1258:14)
    at listen (net.js:1294:10)
    at Server.listen (net.js:1390:5)
    at EventEmitter.listen (F:\webstorm\*****\node_modules\_express@4.15.4                                                                                          @express\lib\application.js:618:24)
    at Object.<anonymous> (F:\webstorm\*****\build\dev-server.js:82:18)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:502:3

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "G:\\Program Files\\nodejs\\node.exe" "G:\\Program Files\\nodejs\\                                                                                          node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v6.11.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! monkey-tell@1.0.0 dev: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the monkey-tell@1.0.0 dev script 'node build/dev-server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the monkey-tell package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/dev-server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs monkey-tell
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls monkey-tell
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     F:\webstorm\***\npm-debug.log


方法:好吧,如标红的地方提示,端口被占用了,那么需要找到端口并杀掉它,重新运行项目就好,步骤如下:

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\***>netstat -aon|findstr "8732"
  TCP    0.0.0.0:8732           0.0.0.0:0              LISTENING       7140
  TCP    [::]:8732              [::]:0                 LISTENING       7140

C:\Users\***>tasklist|findstr "7140"
node.exe                      7140 Console                    1    164,488 K

C:\Users\***>taskkill /f /t /im node.exe
成功: 已终止 PID 7140 (属于 PID 6336 子进程)的进程。

重新运行项目即可:

$ npm run dev

> monkey-tell@1.0.0 dev F:\webstorm\****
> node build/dev-server.js

> Starting dev server...
 DONE  Compiled successfully in 12608ms15:25:35

> Listening at http://localhost:8732


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值