I want to use requireJS for client code. My file structure is:
ProjectRoot
|-server.js
|-public/
|-index.html
|-js/
|-app.js
|-lib/
|-require.min.js
|-underscore.js
|-backbone.js
|-raphael.js
|-app/
|-..
server.js:
var express = require('express');
var app = express();
app.use('/', express.static(__dirname + '/public'));
app.listen(8090);
index.html:
<!DOCTYPE html>
<html>
<body>
</body>
<script src="js/lib/require.min.js" data-main="js/app.js" />
</html>
app.js:
require.config({
paths: {
'jquery': 'lib/jquery',
'raphael': 'lib/raphael'
},
shim: {
'lib/underscore': {
exports: '_'
},
'lib/backbone': {
deps: ["lib/underscore", "jquery"],
exports: 'Backbone'
}
}
});
Problem: When I go to localhost:8090
I get only index.html
without any .js file
Question: why Express does not send javascript to the client?
P.S. But when I go to http://localhost:8090/js/app.js
I get my app.js
Also I launch my app with node server.js
command
Problem 2: My app cannot load data-main
file. Instead of requesting localhost:8090/js/app.js
it asks for localhost:8090/js/app.app
. Why app.app?