Reputation: 1123
How do i load the js of socket.io.js into a variable inside my node server app.
I want to create a route '/jsfile' with express where i send the socket.io.js file + some js functions all in one js.
I can't get the socket.io.js from my server with fs readFile / readFileSync
Upvotes: 1
Views: 39
Reputation: 19708
You need to require
dependencies after installing them via npm
. The readFile API should be used to.. wel read files.
First install socket-io
npm install --save socket-io
Then in your node application, do
var io = require('io');
Upvotes: 2