You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I tried to implement express-ws in my existing project. After it failed it tried the example in a new project. I even done it all in one file and it's not working:
var express = require('express');
var app = express();
var expressWs = require("express-ws")(app);
app.ws('/echo', function(ws, req) {
ws.on('message', function(msg) {
ws.send(msg);
});
});
var router = express.Router();
router.ws('/echo', function(ws, req) {
ws.on('message', function(msg) {
ws.send(msg);
});
});
app.use("/ws-stuff", router);
It's always telling me that "ws" on "router.ws" is an unresolved function.
The text was updated successfully, but these errors were encountered:
This could be caused by express-ws adding the ws function to one version of express in node_modules, and the script getting another version of express from node_modules.
This way app.ws will work, because express.ws gets app as parameter, but router.ws will not work, because it's another version of express.
The solution would be to ensure, there's only one version of express in the codebase.
Hi. I tried to implement express-ws in my existing project. After it failed it tried the example in a new project. I even done it all in one file and it's not working:
It's always telling me that "ws" on "router.ws" is an unresolved function.
The text was updated successfully, but these errors were encountered: