What is the standard way to import JS modules on the client side of a node.js app?
It seems bad to add <script src="..."></script>, but I don't see what else I can do.
Update:
Here is the code of the server:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendfile('index.html');
});
io.on('connection', function(socket){
socket.on('chat message', function(msg){
io.emit('chat message', msg);
});
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
And the client:
<!doctype html>
<html>
<head>
<title>Website</title>
<script src="jquery.js"></script> (doesn't work)
</head>
<body>
</body>
</html>
Do this in your index.js:
var module = require('module');
exports.index = function(req, res) {
res.render('index', { module : module});
//Now your EJS will have the module
}