Problems loading backbonejs and underscorejs with requirejs - backbone.js

I have problems loading this libraries with the shim option in RequireJS (maybe, because my poor background on that library). I try to look in documentation and see some other pages but the problem persist.
This is my app folder structure:
index.html
js/main.js
js/app/router.js
js/app/app.js
js/views/homeview.js
js/libs/backbone/backbone-1.0.0.js
js/libs/underscore/underscore-1.5.1.js
js/libs/jquery/jquery-1.10.2.js
js/libs/require/require-2.1.8.js
All start in index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>App</title>
</head>
<body>
<div class="page">
Loading...
</div>
<script data-main="js/main" src="js/libs/require/require-2.1.8.js"></script>
</body>
</html>
That loads main.js
require.config({
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
},
paths: {
app: 'app',
mod: 'app/mods',
backbone: 'libs/backbone/backbone-1.0.0',
underscore: 'libs/underscore/underscore-1.5.1',
jquery: 'libs/jquery/jquery-1.10.2',
},
});
require([
'app/app',
], function (App) {
App.initialize();
});
That defines the paths to the libraries and the shim options for non-AMD libraries.
Then comes app.js
define([
'app/router',
], function(Router) {
var initialize = function() {
//var router = new Router();
//router.initialize();
Router.initialize();
};
return {
initialize: initialize,
};
});
Then router.js:
define([
'jquery',
'underscore',
'backbone',
'app/views/homeview',
], function($, _, Backbone, HomeView) {
var AppRouter = Backbone.Router.extend({
routes: {
'': 'home',
}
});
var initialize = function() {
var appRouter = new AppRouter();
var homeView = new HomeView();
appRouter.on('route:home', function() {
userListView.render();
console.log('We have loaded the home page.');
});
Backbone.history.start();
};
return {
initialize: initialize,
};
});
Now here i have a problem beacause looking at the network tab in the chrome developer tools only jquery loads, nor backbone or underscore.
Then, and finally, because it's defined a reference to a view, loads homeview.js
define([
'jquery',
'underscore',
'backbone',
'libs/text!app/tpl/home.html',
], function($, _, Backbone, HomeTpl) {
var homeView = Backbone.View.extend({
el: '.page',
render: function() {
//var self = this;
//users.fetch({
// success: function() {
var template = _.template(HomeTpl, {});
//self.$el.html(template);
this.$el.html(template);
// }
//});
},
});
return homeView;
});
And the problem, because at line var homeView = Backbone.View.extend({ shows the error: "Uncaught TypeError: Cannot read property 'View' of undefined", but i think that's because backbone never loads.
¿Can anyone tell what i'm doing terribly wrong? I looking the code and several pages all day and i cannot figure it out the answer. Thanks in advance and apoliges for the long question, buy i've seen many people having this same issue and maybe the answer could help others too.

Can't find anything wrong, but you don't need to load the app modules in the paths
paths: {
app: 'app', // remove

Related

A simple hello world angularjs code not working with cordova android

index.html
<body>
<div ng-app="myapp">
<div ng-controller="HelloController" >
<h2>Welcome {{hello.title}} to the world Mr. {{hello.myname}}!</h2>
</div>
</div>
<script src="cordova.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="js/index.js"></script>
</body>
index.js
document.addEventListener('deviceready', function() {
var myapp = angular.module("myapp", []);
myapp.controller("HelloController", function($scope) {
console.log("inside controller");
$scope.hello = {};
$scope.hello.title = "AngularJS";
$scope.hello.myname = "hello";
});
}, false);
Error displayed in logcat
02-11 14:52:19.835: I/chromium(2955): [INFO:CONSOLE(40)] "Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=myapp&p1=Error%3A%20%5B%24injector%3Anomod%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.5.0%2F%24injector%2Fnomod%3Fp0%3Dmyapp%0A%20%20%20%20at%20Error%20(native)%0A%20%20%20%20at%20file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A6%3A416%0A%20%20%20%20at%20file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A25%3A136%0A%20%20%20%20at%20b%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A24%3A188)%0A%20%20%20%20at%20file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A24%3A431%0A%20%20%20%20at%20file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A39%3A357%0A%20%20%20%20at%20n%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A7%3A355)%0A%20%20%20%20at%20g%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A39%3A135)%0A%20%20%20%20at%20fb%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A43%3A164)%0A%20%20%20%20at%20Ac.c%20(file%3A%2F%2F%2Fandroid_asset%2Fwww%2Fbower_components%2Fangular%2Fangular.min.js%3A20%3A449)", source: file:///android_asset/www/bower_components/angular/angular.min.js (40)
Detailed error displayed in catlog
02-11 15:35:37.334: E/Web Console(24865): Uncaught Error: [$injector:nomod] Module 'myapp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
What I am missing, The same code code works in a browser
I would recommend you to use RequireJS technique
It requires multiple files as below
index.html
<body>
<div id="controller" ng-app="app" ng-controller="HelloController" style="display:none">
<h2>Welcome {{hello.title}} to the world Mr. {{hello.myname}}!</h2>
</div>
<script src="cordova.js"></script>
<script src="bower_components/requirejs/require.js" data-main="js/main.js"></script>
</body>
main.js
require.config({
paths: {
'domReady': '../bower_components/domReady/domReady',
'angular': '../bower_components/angular/angular'
},
shim: {
'angular': {
exports: 'angular'
}
},
deps: ['./bootstrap']
});
bootstrap.js
define(['require','angular','app'], function (require, ng) {
require(['domReady!'], function (document) {
ng.bootstrap(document, ['app']);
});
});
app.js
define(['angular'], function (ng) {
var mod = ng.module('app', []);
mod.controller("HelloController", function($scope) {
$scope.hello = {
title: "angularjs",
myname: "hello"
}
document.getElementById("controller").style.display = "block";
});
return mod;
});
The reason we are using shim in the require.config is that the angularJS does not support AMD so we expose it as an object via RequireJS
I used document.getElementById("controller").style.display = "block"; to avoid the template html to appear without the values rendered

how to bind click event in angular js using requirejs?

could you please tell me how to bind click event using require js + angularjs
I try to bind the click event but it is bind the click event
Here is my code
index.html
<!DOCTYPE html>
<html>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<head>
<link type="text/css" href="http://code.ionicframework.com/1.0.0-beta.1/css/ionic.css" rel="stylesheet" />
</head>
<body>
<ion-nav-view animation="slide-left-right"></ion-nav-view>
<script data-main="main" src="lib/require.js"></script>
</body>
</html>
main.js
requirejs.config({
paths: {
ionic:'lib/ionic.bundle'
},
shim: {
ionic : {exports : 'ionic'}
}, priority: [
'ionic'
],
deps: [
'bootstrap'
]
});
bootstrap.js
/*global define, require, console, cordova, navigator */
define(['ionic', 'app', 'routes'], function (ionic, angular, app) {
'use strict';
var $html,
onDeviceReady = function () {
angular.bootstrap(document, [app.name]);
};
document.addEventListener("deviceready", onDeviceReady, false);
if (typeof cordova === 'undefined') {
$html = angular.element(document.getElementsByTagName('html')[0]);
angular.element().ready(function () {
try {
angular.bootstrap(document, [app.name]);
} catch (e) {
console.error(e.stack || e.message || e);
}
});
}
});
app.js
/*global define, require */
define(['ionic'],
function (angular) {
'use strict';
var app = angular.module('app', [
'ionic']);
return app;
});
You have a few bugs in your code... too many too list them all. See Plunker for the corrections.
The module ionic should be exported as angular.
requirejs.config({
paths: {
ionic:'lib/ionic.bundle'
},
shim: {
ionic : {exports : 'angular'}
}, priority: [
'ionic'
],
deps: [
'bootstrap'
]
});
Ionic/Angular must be loaded first - or angular can't initialize itself.
In the routes you have to reference the controller by name - not by location
/*global define, require */
define(['app'], function (app) {
'use strict';
app.config(['$stateProvider', '$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('login', {
url: "/login",
templateUrl: "login.html",
controller: 'controllers/LoginCtrl' // <-- should be 'LoginCtrl'
})
$urlRouterProvider.otherwise("/login");
}]);
});

I have hit an AngularJS wall

I am trying to pick AngularJS back up. I created a site with a previous version of AngularJS and RequireJS and never had this issue, I have searched and searched and still cannot get this to work so I am reaching out. I am trying to use RequireJS 2.1.15 and AngularJS 1.3.11. When trying to load up my main page I am getting the following:
Uncaught Error: [$injector:modulerr] Failed to instantiate module rehyveApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
Error: [$injector:nomod] Module 'ngRoute' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.3.11/$injector/nomod?p0=ngRoute
at http://127.0.0.1:64216/js/lib/angular.js:63:12
at http://127.0.0.1:64216/js/lib/angular.js:1764:17
at ensure (http://127.0.0.1:64216/js/lib/angular.js:1688:38)
at module (http://127.0.0.1:64216/js/lib/angular.js:1762:14)
at http://127.0.0.1:64216/js/lib/angular.js:4094:22
at forEach (http://127.0.0.1:64216/js/lib/angular.js:323:20)
at loadModules (http://127.0.0.1:64216/js/lib/angular.js:4078:5)
at http://127.0.0.1:64216/js/lib/angular.js:4095:40
at forEach (http://127.0.0.1:64216/js/lib/angular.js:323:20)
at loadModules (http://127.0.0.1:64216/js/lib/angular.js:4078:5)
http://errors.angularjs.org/1.3.11/$injector/modulerr?p0=ngRoute&p1=Error%3…dules%20(http%3A%2F%2F127.0.0.1%3A64216%2Fjs%2Flib%2Fangular.js%3A4078%3A5)
at http://127.0.0.1:64216/js/lib/angular.js:63:12
at http://127.0.0.1:64216/js/lib/angular.js:4117:15
at forEach (http://127.0.0.1:64216/js/lib/angular.js:323:20)
at loadModules (http://127.0.0.1:64216/js/lib/angular.js:4078:5)
at http://127.0.0.1:64216/js/lib/angular.js:4095:40
at forEach (http://127.0.0.1:64216/js/lib/angular.js:323:20)
at loadModules (http://127.0.0.1:64216/js/lib/angular.js:4078:5)
at createInjector (http://127.0.0.1:64216/js/lib/angular.js:4004:11)
at doBootstrap (http://127.0.0.1:64216/js/lib/angular.js:1446:20)
at Object.bootstrap (http://127.0.0.1:64216/js/lib/angular.js:1467:12)
http://errors.angularjs.org/1.3.11/$injector/modulerr?p0=rehyveApp&p1=Error…trap%20(http%3A%2F%2F127.0.0.1%3A64216%2Fjs%2Flib%2Fangular.js%3A1467%3A12)
Here is my index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-theme.css">
</head>
<body>
<div class="container">
Load Main View
</div>
<div class="container">
<ng-view></ng-view>
</div>
<script src="js/require.js" data-main="js/main.js"></script>
</body>
</html>
Here is my main.js:
require.config({
paths: {
base: "/js",
lib: "/js/lib"
},
shim: {
'lib/bootstrap': {
deps: ['lib/jquery']
},
'lib/angular': {
deps: ['lib/jquery']
},
'lib/angular-route': {
deps: ['lib/angular']
},
'lib/angular-resource': {
deps: ['lib/angular']
},
'lib/ui-bootstrap': {
deps: ['lib/angular']
},
'base/app': {
deps: ['lib/angular', 'lib/angular-route']
},
'base/controllers/mainController': {
deps: ['base/app']
}
}
});
define(['lib/jquery', 'lib/angular', 'lib/angular-route', 'lib/angular-resource', 'lib/ui-bootstrap', 'base/app', 'base/controllers/mainController'], function () {
angular.element(document).ready(function() {
angular.module('rehyveApp', ['ngRoute']);
angular.bootstrap(document, ['rehyveApp']);
});
});
Here is my app.js:
'use strict';
define(['lib/angular'], function () {
var rehyveApp = angular.module('rehyveApp', ['ngRoute'])
.config(function ($routeProvider) {
$routeProvider.when('/main',
{
templateUrl: 'templates/main.html',
controller: 'mainController'
});
$routeProvider.otherwise({redirectTo: 'main'});
});
return rehyveApp;
});
and my mainController.js:
'use strict';
define(['base/app'], function (rehyveApp) {
var rehyveApp = angular.module('rehyveApp',[]);
rehyveApp.controller('mainController', ['$scope', function ($scope) {
$scope.testdata = {
name: 'mainController working'
}
}]);
});
Any help would be greatly appreciated. Thank you in advance.
So it turns out that it was an issue with the 1.3.11 version of the angular-route.js lib, they just released a 1.3.12 and after copying that in, everything is working now. Thank you all for looking into this.
You forgot 'lib/angular-route' in your define at app.js. See that you are using ngRoute but not importing it.
define(['lib/angular','lib/angular-route'], function () {

RequireJS + AngularJS + Module: Dependency issues

I had my angularjs app setup in local and everything was working fine till I upload my code to the staging server. I now have issue with dependencies that are not respected but I can't see why. I guess it was working in local because it was loading the library faster. I now modified my app to try to fix this issue but can't manage to make it work.
My application is loading a single page app, composed of 3 views (main, map and map-data). I'm using AngularJS modules structure to launch this app. Here is my directory structure:
The index.html is pretty basic:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0" />
<title>Map Application</title>
<link rel="icon" sizes="16x16" href="/favicon.ico" />
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key={{ map_key }}&sensor=false"></script>
<script type="text/javascript" src="/js/bower_components/requirejs/require.js"></script>
<link rel="stylesheet" href="/css/main.css" media="screen" type="text/css">
<link rel="stylesheet" href="/js/bower_components/bootstrap/dist/css/bootstrap.css">
</head>
<body>
<!-- Content -->
<div id="content" data-ui-view></div>
<script>
// obtain requirejs config
require(['require', 'js/require-config'], function (require, config) {
// set cache beater
config.urlArgs = 'bust=v{{ version }}';
// update global require config
window.require.config(config);
// load app
require(['main']);
});
</script>
</body>
</html>
Then requirejs-config.js:
if (typeof define !== 'function') {
// to be able to require file from node
var define = require('amdefine')(module);
}
define({
baseUrl: 'js', // Relative to index
paths: {
'jquery': 'bower_components/jquery/dist/jquery.min',
'underscore': 'bower_components/underscore/underscore-min',
'domReady': 'bower_components/requirejs-domready/domReady',
'propertyParser': 'bower_components/requirejs-plugins/src/propertyParser',
'async': 'bower_components/requirejs-plugins/src/async',
'goog': 'bower_components/requirejs-plugins/src/goog',
'angular': 'bower_components/angular/angular',
'ngResource': 'bower_components/angular-resource/angular-resource',
'ui.router': 'bower_components/angular-ui-router/release/angular-ui-router',
'angular-google-maps': 'bower_components/angular-google-maps/dist/angular-google-maps',
'moment': 'bower_components/momentjs/moment',
'moment-timezone': 'bower_components/moment-timezone/moment-timezone',
'moment-duration-format': 'bower_components/moment-duration-format/lib/moment-duration-format'
},
shim: {
'angular': {
exports: 'angular'
},
'ngResource': ['angular'],
'ui.router' : ['angular']
}
});
Then the main.js:
/**
* bootstraps angular onto the window.document node
* NOTE: the ng-app attribute should not be on the index.html when using ng.bootstrap
*/
define([
'require',
'angular',
'./app'
], function (require, angular) {
'use strict';
/**
* place operations that need to initialize prior to app start here
* using the `run` function on the top-level module
*/
require(['domReady!'], function (document) {
angular.bootstrap(document, ['app']);
});
});
Then the app.js:
/**
* loads sub modules and wraps them up into the main module
* this should be used for top-level module definitions only
*/
define([
'angular',
'ui.router',
'./config',
'./modules/map/index'
], function (ng) {
'use strict';
return ng.module('app', [
'app.constants',
'app.map',
'ui.router'
]).config(['$urlRouterProvider', function ($urlRouterProvider) {
$urlRouterProvider.otherwise('/');
}]);
});
Here you can see that the app.js depends on the ./modules/map/index, where I'm loading all available controllers:
/**
* Loader, contains list of Controllers module components
*/
define([
'./controllers/mainCtrl',
'./controllers/mapCtrl',
'./controllers/mapDataCtrl'
], function(){});
Each controller are requesting the same kind of module, here is mapDataCtrl.js which is the one that is triggered by /:
/**
* Map Data controller definition
*
* #scope Controllers
*/
define(['./../module', 'moment'], function (controllers, moment) {
'use strict';
controllers.controller('MapDataController', ['$scope', 'MapService', function ($scope, MapService)
{
var now = moment();
$scope.data = {};
$scope.data.last_update = now.valueOf();
$scope.data.time_range = '<time range>';
$scope.data.times = [];
var point = $scope.$parent.map.center;
MapService.getStatsFromPosition(point.latitude, point.longitude).then(function(data){
$scope.data.times = data;
});
}]);
});
As you can see, the controller is requesting module.js where the states and module name are defined:
/**
* Attach controllers to this module
* if you get 'unknown {x}Provider' errors from angular, be sure they are
* properly referenced in one of the module dependencies in the array.
* below, you can see we bring in our services and constants modules
* which avails each controller of, for example, the `config` constants object.
**/
define([
'angular',
'ui.router',
'../../config',
'underscore',
'angular-google-maps',
'./services/MapService'
], function (ng) {
'use strict';
return ng.module('app.map', [
'app.constants',
'ui.router',
'angular-google-maps'
]).config(['$stateProvider', '$locationProvider', function ($stateProvider, $locationProvider) {
$stateProvider
.state('main', {
templateUrl: '/js/modules/map/views/main.html',
controller: 'MainController'
})
.state('main.map', {
templateUrl: '/js/modules/map/views/main.map.html',
controller: 'MapController',
resolve: {
presets: ['MapService', function(MapService){
return MapService.getPresets();
}],
courses: ['MapService', function(MapService){
return MapService.getCourses()
}]
}
})
.state('main.map.data', {
url: '/',
templateUrl: '/js/modules/map/views/main.map.data.html',
controller: 'MapDataController'
})
;
//$locationProvider.html5Mode(true);
}]);
});
It's in this file that I have an issue. I'm trying to load the module angular-google-maps because I need it in my MapCtr controller and most probably in MapDataCtrl. But I get the following message:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module app.map due to:
Error: [$injector:modulerr] Failed to instantiate module angular-google-maps due to:
Error: [$inj...<omitted>...1)
I have no idea what I am missing, for me everything looks tied correctly. What am I missing?
UPDATE 1
I think it's because angular-google-map is not AMD compliant, so I've modified my requirejs-config.js as follow:
if (typeof define !== 'function') {
// to be able to require file from node
var define = require('amdefine')(module);
}
define({
baseUrl: 'js', // Relative to index
paths: {
...
'underscore': 'bower_components/underscore/underscore-min',
'angular-google-maps': 'bower_components/angular-google-maps/dist/angular-google-maps',
...
},
shim: {
'angular': {
exports: 'angular'
},
'ngResource': ['angular'],
'ui.router' : ['angular'],
'angular-google-maps': {
deps: ["underscore"],
exports: 'angular-google-maps'
}
}
});
but I still have the same issue.
We can use an js library with require.js.There is no need to remove require.js. I still need to check why require.js config not working.
Meanwhile you can try this way.
// requirejs-config.js
define({
baseUrl: 'js', // Relative to index
paths: {
'jquery': 'bower_components/jquery/dist/jquery.min',
'underscore': 'bower_components/underscore/underscore-min',
'domReady': 'bower_components/requirejs-domready/domReady',
'propertyParser': 'bower_components/requirejs-plugins/src/propertyParser',
'async': 'bower_components/requirejs-plugins/src/async',
'goog': 'bower_components/requirejs-plugins/src/goog',
'angular': 'bower_components/angular/angular',
'ngResource': 'bower_components/angular-resource/angular-resource',
'ui.router': 'bower_components/angular-ui-router/release/angular-ui-router',
'angular-google-maps': 'bower_components/angular-google-maps/dist/angular-google-maps',
'moment': 'bower_components/momentjs/moment',
'moment-timezone': 'bower_components/moment-timezone/moment-timezone'
},
shim: {
'angular': {
exports: 'angular'
},
'ngResource': ['angular'],
'ui.router' : ['angular']
}
});
// google-map.js
define(['underscore', 'angular-google-maps'], function(){
});
And then requiring the module each time I need the map:
require(['google-map'], function(){
});
https://github.com/angular-ui/angular-google-maps/issues/390

Adding module causes additional http request

When adding a Backstack as a module for a test app in my router file it throws a error 404 loading backbone.js
I can't figure out what is the cause, but an extra http get is added that requests js/Backbone.js which then throws a 404 as I only have my libs in the js/libs folder.
What could be the issue?
// index.html
<!DOCTYPE html>
<html>
<head>
<title>Starting Require</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"/>
<script data-main="js/main" src="js/libs/require.js"></script>
</head>
<body>
<div id="content">
</div>
</body>
// main.js
requirejs.config({
paths : {
'jquery' : 'libs/jquery-1.8.2.min',
'underscore' : 'libs/underscore',
'backbone' : 'libs/backbone',
'backstack' : 'https://github.com/pwalczyszyn/backstack/blob/master/backstack'
},
shim: {
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'backstack': {
deps: ['backbone', 'underscore', 'jquery'],
},
'underscore': {
exports: '_'
}
}
});
require([
'app',
], function(App){
App.initialize();
});
// app.js
define([
'jquery',
'underscore',
'backbone',
'router'
], function($, _, Backbone, Router){
var initialize = function(){
Router.initialize();
};
return {
initialize: initialize
};
});
// router.js
define([
'jquery',
'underscore',
'backbone',
'backstack'
], function($, _, Backbone, Backstack) {
var AppRouter = Backbone.Router.extend({
routes: {
'': 'welcome'
}
});
var initialize = function(){
var app_router = new AppRouter;
app_router.on('route:welcome', function(){
$('#content').html('Hello World!');
});
};
return {
initialize: initialize
};
});
backstack uses the Backbone module name, not backbone.
This fiddle uses only a capitalised Backbone module name and has no extra module load.
http://jsfiddle.net/MUSBk/
Or else you could define an alias (omit the module name if you place in a file called Backbone.js) - http://jsfiddle.net/3UXGZ/1/
define('Backbone', ['backbone'], function (Backbone) {
return Backbone;
});
I'm not sure you can use your path config to point a new Backbone module to your existing Backbone JS, as this would probably load the same file as a second instance of Backbone, which might cause issues.

Resources