Typeerror:arguments to Path.join must is strings at F (path.js:204:15) at object.filter (native) at exports . Join (path.js:209:40) at exports.send (E:\nodejs\demo\socket.io-express\node_modules\express\node_modules\ CONNECT\LIB\MIDDLEWARE\STATIC.JS:129:20) at ServerResponse.res.sendfile (E:\nodejs\demo\socket.io-express\ Node_modules\express\lib\response.js:186:3) at Io.sockets.on.socket.emit.text (E:\nodejs\demo\ Socket.io-express\app.js:8:6) at callbacks (E:\nodejs\demo\socket.io-express\node_modules\express\lib\router \index.js:272:11) at param (e:\nodejs\demo\socket.io-express\node_modules\express\lib\router\index.js:246:11 ) at Pass (e:\nodejs\demo\socket.io-express\node_modules\express\lib\router\index.js:253:5) at Router._ Dispatch (E:\nodejs\demo\socket.io-express\node_modules\express\lib\router\index.js:280:5)
The following error occurred when the two modules in node. js were integrated with Express Socket.io:
var express = require (' Express '), var app = Module.exports = Express.createserver (), io = require (' Socket.io '). Listen (app); App.listen (3000); App.get ('/', function (req, res) { res.sendfile (__dirname + '/index.html ');}); Io.sockets.on (' Connection ', function (socket) { socket.emit (' welcome ', {text: ' OH hai! U R connected! '});
Cause of Error:
The main cause of the error is the 8th line of code above, which changes the code to work in the following form.
var express = require (' Express '), var app = Module.exports = Express.createserver (), io = require (' Socket.io '). Listen (app); app.listen; App.get ('/', function (req, res) {res.sendfile ('/index.html ', {root: __dirname});}); Io.sockets.on (' Connection ', function (socket) {socket.emit (' welcome ', {text: ' OH hai! U R CONNECTED '});
In win down the pass
__dirname + '/index.html ' - e:\nodejs\demo/index.html
Seemingly, there is a URL parsing module. The result of the final parsing is not the way Windows looks like:
Then the path is wrong when the flow is created ...
Reference: Https://github.com/visionmedia/send