[nodemon] app crashed - waiting for file changes before starting...解决方法
程序员文章站
2022-06-01 09:20:48
...
安装时出现的问题及解决方法:
[nodemon] starting `node app.js`
events.js:291
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1316:16)
at listenInCluster (net.js:1364:12)
at Server.listen (net.js:1450:7)
at Application.listen (/Users/edz/Documents/ketang/firstServer/node_modules/koa/lib/application.js:82:19)
at Object.<anonymous> (/Users/edz/Documents/ketang/firstServer/app.js:70:22)
at Module._compile (internal/modules/cjs/loader.js:1256:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
at Module.load (internal/modules/cjs/loader.js:1105:32)
at Function.Module._load (internal/modules/cjs/loader.js:967:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1343:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
error:[nodemon] app crashed - waiting for file changes before starting...
解决方法:
^CedzdeMacBook-Air:firstServer edz$ lsof -i tcp:3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google 373 edz 20u IPv6 0x24a988475a8be9bb 0t0 TCP localhost:61623->localhost:hbci (CLOSE_WAIT)
Google 373 edz 28u IPv6 0x24a988475a8bfafb 0t0 TCP localhost:61624->localhost:hbci (CLOSE_WAIT)
node 23731 edz 24u IPv6 0x24a988475a8c067b 0t0 TCP *:hbci (LISTEN)
wxldeMacBook-Air:firstServer edz$ kill 23731//杀死最后一个 23731
edzdeMacBook-Air:firstServer edz$ lsof -i tcp:3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google 373 edz 20u IPv6 0x24a988475a8be9bb 0t0 TCP localhost:61623->localhost:hbci (CLOSE_WAIT)
Google 373 edz 28u IPv6 0x24a988475a8bfafb 0t0 TCP localhost:61624->localhost:hbci (CLOSE_WAIT)//检查是否成功
edzdeMacBook-Air:firstServer edz$ nodemon app.js
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node app.js`
Listening on http://localhost:3000
//出现以上内容,成功