首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >npm启动时出错。错误:听EADDRINUSE:已在使用的地址:5000

npm启动时出错。错误:听EADDRINUSE:已在使用的地址:5000
EN

Stack Overflow用户
提问于 2022-06-17 18:23:40
回答 1查看 509关注 0票数 1

对我来说,这可能是同样的问题:MongoDB/React Error: listen EADDRINUSE: address already in use :::5000

我尝试了"npx kill-port 5000“的方法,它写着”5000端口上的进程被杀死“。然而,我再次运行"npm“,它只是给了我同样的错误。

这是我的服务器index.js

代码语言:javascript
运行
复制
import express from "express";
import bodyParser from "body-parser";
import mongoose from "mongoose";
import cors from "cors";

const app = express();

app.use(bodyParser.json({ limit: "30mb", extended: true }));
app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }));
app.use(cors());

const CONNECTION_URL = 'mongodb+srv://weiz:123456wz@cluster0.s6fc6.mongodb.net/?retryWrites=true&w=majority';
const PORT = process.env.PORT || 5000;

mongoose.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
    .then(() => app.listen(PORT, () => console.log("Server running on port: 5000"))) //useless
    .catch((error) => console.log(error.message));


mongoose.connect(CONNECTION_URL).then(() => { console.log('...') });

这是我的错误

代码语言:javascript
运行
复制
apple@3 server % npm start

> server@1.0.0 start
> nodemon index.js

[nodemon] 2.0.16
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
...
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::5000
    at Server.setupListenHandle [as _listen2] (node:net:1372:16)
    at listenInCluster (node:net:1420:12)
    at Server.listen (node:net:1508:7)
    at Function.listen (/Users/apple/Desktop/memories_project/server/node_modules/express/lib/application.js:635:24)
    at file:///Users/apple/Desktop/memories_project/server/index.js:23:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1399:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -48,
  syscall: 'listen',
  address: '::',
  port: 5000
}
[nodemon] app crashed - waiting for file changes before starting...

如果需要提供更多代码,我将添加它们。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-19 21:36:08

我最终通过更新我的mac系统解决了这个问题。我想在旧的系统版本中,我的airplay功能一定有问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72663394

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档