'can't fix ExpressPeerServer is not a function in server.js
I am stuck in a error where I have successfully installed peer.js library in my npm project but in my server.js file, when I try to import peer library and use it as a function, it is saying that peerServer is not a function.
const express = require('express');
const app = express()
const server = require("http").Server(app);
const {v4:uuidv4} = require("uuid")
const io = require("socket.io")(server);
const peerServer = require("peer");
const ExpressPeerServer = peerServer(server, {
debug: true,
})
app.use(express.static('public'));
app.set('view engine', 'ejs');
app.get("/", (req, res)=>{
res.redirect(`/${uuidv4()}`)
})
app.get('/:room', (req, res)=>{
res.render('room', {roomId : req.params.room})
})
server.listen(3000, ()=>{
console.log("Server is running on port 3000")
})
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pierre Noyelle |

