node server.js
Error: listen EACCES: permission denied 192.168.1.117
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1345:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EACCES',
errno: -4092,
syscall: 'listen',
address: '192.168.1.117',
port: -1
const express = require('express')
const app = express()
const server = require('http').Server(app)
const io = require('socket.io')(server)
const { v4: uuidV4 } = require('uuid')
app.set('view engine', 'ejs')
app.use(express.static('public'))
app.get('/', (req, res) => {
res.redirect(`/${uuidV4()}`)
})
app.get('/:room', (req, res) => {
res.render('room', { roomId: req.params.room })
})
io.on('connection', socket => {
socket.on('join-room', (roomId, userId) => {
socket.join(roomId)
socket.to(roomId).broadcast.emit('user-connected', userId)
console.log("User connected")
socket.on('disconnect', () => {
socket.to(roomId).broadcast.emit('user-disconnected', userId)
console.log("user disconnected")
})
})
})
server.listen(3000)
我尝试更改端口。我真的不知道为什么有人很难在他们的本地网络上托管 Nodejs 应用程序