节点 Js 调试器地址已在使用中



我是学习 Node Js 的初学者,我正在尝试调试,但我收到此错误:

Waiting for the dError: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1300:14)
at listenInCluster (net.js:1348:12)
at Server.listen (net.js:1436:7)
at Function.listen (c:UsersHpDesktopNodeonline-shopnode_modulesexpresslibapplication.js:618:24)
at Object.<anonymous> (c:UsersHpDesktopNodeonline-shopapp.js:26:5)
at Module._compile (internal/modules/cjs/loader.js:953:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1327:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
ebugger to disconnect...

我已经尝试了端口 3001 和其他端口,但仍然收到相同的错误

这是我的launch.json文件:

{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}\app.js"
}
]
}

这是我的应用程序.js文件

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`server started on port ${PORT}`));

使用npm startyarn start停止运行应用,然后再次尝试调试。您不能同时运行应用程序和调试两者。节点调试器会将应用程序运行到指定的端口中。

相关内容

  • 没有找到相关文章

最新更新