I was trying to create a simple chat-room using express and socket.io but I encountered with an error while running the server. Can someone help?
Server.js
const express = require("express");
const path = require("path");
const app = express();
const server = require("http").createServer(app);
const io = require("socket.io")(server);
app.use(express.static(path.join(__dirname+"/public")));
io.on("connection", function(socket){
socket.on("newuser",function(username){
socket.broadcast.emit("update", username + " joined the conversation");
});
socket.on("exituser",function(username){
socket.broadcast.emit("update", username + " left the conversation");
});
socket.on("chat",function(message){
socket.broadcast.emit("chat", message);
});
});
server.listen(5000);
After entering node server.js on the command prompt I see this error
Error Message:
app.use(express.static(path.join(__dirname*/public)));
^
SyntaxError: Invalid regular expression: missing /
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47