Cuando se usa npm run dev para iniciar el proyecto front-end, se informa un error: Error: escucha EADDRINUSE: la dirección ya está en uso 0.0.0.0:8090

Descripción del problema:

Cuando se usa npm run dev para iniciar un proyecto front-end, a menudo se encuentra que un determinado puerto está ocupado , lo que resulta en la imposibilidad de acceder a la página normalmente, y el error es el siguiente:

Error: listen EADDRINUSE: address already in use 0.0.0.0:8090
    at Server.setupListenHandle [as _listen2] (net.js:1331:16)
    at listenInCluster (net.js:1379:12)
    at doListen (net.js:1516:7)
    at processTicksAndRejections (internal/process/task_queues.js:83:21) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '0.0.0.0',
  port: 8090
}

Solución:
1. Puede usar el siguiente comando para averiguar qué procesos ocupan el puerto actual

sudo lsof -i tcp:8090

2. Después de ejecutar el comando anterior, se encuentran estos procesos (ocupados por nginx)

xxx@xxx-xxx:/var/www/client/src$  lsof -i tcp:8090
COMMAND    PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
node    807863  zph   21u  IPv4 17021269      0t0  TCP *:8090 (LISTEN)

3. Mata los procesos usando el siguiente comando


xxx@xxx-xxx:/var/www/client/src$ kill -9 807863

4. Vuelva a ejecutar npm run dev para iniciar el proyecto front-end y volver a la normalidad

xxx@xxx-xxx:/var/www/client/src npm run dev

> [email protected] dev /var/www/client> preact watch

BUILD_FOR undefined
 Build  [                    ] 0% (0.0s) compiling
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8090/
<i> [webpack-dev-server] On Your Network (IPv4): http://xxx:8090/
<i> [webpack-dev-server] Content not from webpack is served from '/var/www/client/src' directory
<i> [webpack-dev-server] 404s will fallback to '/index.html'
Compiled successfully!

You can view the application in browser.

Local:            http://0.0.0.0:8090
On Your Network:  http://xxx:8090

 Build  [                    ] 0% (12.3s) compiling
Compiled successfully!

You can view the application in browser.

Local:            http://0.0.0.0:8090
On Your Network:  http://xxx:8090

 

Supongo que te gusta

Origin blog.csdn.net/zhoupenghui168/article/details/132160114
Recomendado
Clasificación