node.js + express + socket.io cannot load javascript files into index.html
If the HTML file is located in the same path as the scripts are, then use relative path like src = "main.js"
. If it still doesn't work, maybe it's Express' fault.
Add the codes below into your app.js
:
app.use(express.static(__dirname + '/scripts'));
And the scripts can be accessed from the path relative to /scripts
- e.g. main.js
from http://yourdomain/script.js
but not from http://yourdomain/scripts/main.js
.Sorry for my English.