I'm working on a personal project and I'm using a lot of JavaScript code and working with a few libraries and plugins like jQuery and Velocity.js. I don't know why I can't make it working, I've followed the RequireJS documentation and a lot of tutorials, but I'm always getting errors in the console.
This is how my website's depository is like:
Main folder
|
|index.html
|
|
|——JS folder ——
|
|require.js
|config.js
|main.js
|
|————————
In index.html I'm calling the RequireJS in this way
<script data-main="js/config" src="js/require.js"></script>
And in the config I have the paths for each CDN depositories, like this:
requirejs.config({
"baseUrl": "js",
"paths": {
"jquery": "//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js",
"velocity": "//cdn.jsdelivr.net/velocity/1.2.2/velocity.min.js",
"velocity-ui": "//cdn.jsdelivr.net/velocity/1.2.2/velocity.ui.min.js",
"bootstrap": "//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js",
"main": "main"
}
});
In the same file (config.js), after closing the requirejs.config I'm calling my main.js file in this way:
require(['main']);
And inside the main.js I'm using jquery, velocity and velocity-ui.
require([ "jquery", "velocity", "velocity-ui" ], function ($, Velocity) {
//my code here
});
After that, I'm always getting errors in console, like
Error: Script error for: jquery
http://requirejs.org/docs/errors.html#scripterror
---
Error: Script error for: velocity
http://requirejs.org/docs/errors.html#scripterror
---
Error: Script error for: velocity-ui
http://requirejs.org/docs/errors.html#scripterror
I don't know what I'm doing wrong ...