node.js - Socket IO, in which directory should i save my static javascript files -


i trying include jquery in socket io served file served -

app.get('/:file', function(req, res){     res.set('content-type', 'text/html');     res.sendfile('shrib.html'); }); 

now in shrib.html when try send -

<script type="text/javascript" src="/jquery-1.11.0.min.js"></script> 

or

<script type="text/javascript" src="jquery-1.11.0.min.js"></script> 

i error of jquery not found, when try use cdn version of jquery runs fine. in directory structure have jquery-1.11.0.min.js in both main directory , in node_modules directory yet don't see , error -

uncaught syntaxerror: unexpected token < jquery-1.11.0.min.js:1 uncaught referenceerror: $ not defined  

did mistaken socket.io express?

because problem looks related express, not socketio, , see no sockets here...

if yes, should set static files this:

app.use('/js', express.static(__dirname + '/js')); 

put js files in project/js folder, , do:

<script type="text/javascript" src="/js/jquery-1.11.0.min.js"></script> 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -