I have the following file structure:
|- index.html
vendor
|- jquery.min.js (some libraries)
js
|- app.js
When I try to load the index.html from my browser using the following url:
http://localhost/~myname/WebFrontend/
I get the following error in conf.js (see the comments on conf.js).
How should I fix this problem?
// index.html
<script data-main="js/conf" src="./vendor/require.js"></script>
// conf.js
requirejs.config({
baseUrl: '../vendor',
paths: {
jquery: 'jquery.min', // it works
}
});
require(['../js/app']); // http://localhost/~mynane/js/router.js not found
require(['./js/app']); // http://localhost/~myname/vendor/js/router.js not found
// I would like to point to http://localhost/~antoniopierro/WebFrontend/js/router.js
Not sure it will be possible to change the baseUrl on the same file.
And also if you load another module I don’t think you can change the baseUrl.
Anyway:
1) You said jquery module is successfully load.
It is false because you don’t get the error just because the
require(['../js/app']);fails.2) With your structure I suggest to define the
baseUrl: './'.In this way you will be able to access the vendor modules making
vendor/filenameand your source files makingjs/filenane.