33

I'm trying to install backbone.marionette from NPM with the JSPM for client dependency resolving. A simple operation with the following command in commandprompt:

jspm install marionette=npm:backbone.marionette

All dependencies - except jQuery is automatically downloaded and installed. But I get a runtime error:

Can't call Deferred of undefined.

I was looking into the code, and i found that the problem was in the backbone source code line 9, 10 and 11

} else if (typeof exports !== 'undefined') {
  var _ = require("underscore");
  factory(root, exports, _);

When running under traceurJS, the factory-method is called from here, and it is clear, that the last argument $, is left out. When I look in the backbone sourcecode on github, the same lines look like this:

} else if (typeof exports !== 'undefined') {
var _ = require('underscore'), $;
try { $ = require('jquery'); } catch(e) {}
factory(root, exports, _, $);

Here the jQuery dependency is added with option (try/catch). I have to add here, that the NPM version is marked with the same version as GitHub - 1.1.2.

Why the difference? It seems as if this has been a problem for some time as of, there is published a few workarounds like adding this in code:

$           = require('jquery');
Backbone    = require('backbone');
Backbone.$  = $

I don't like this, although it works, because its a workaround, and it seems as if it's not existing.

Ying-Shan Lin
  • 607
  • 5
  • 22
Jesper Jensen
  • 835
  • 8
  • 16
  • 1
    I found out, that the current release of backbone (1.1.2), has this bug, and github reflects current state of development (with a fix), so I guess that this issue, is solved, when the project is released next. Sorry, but this question, should not have been asked, and I can't figure out how to remove it! – Jesper Jensen Apr 27 '15 at 08:45
  • Backbone now in version 1.2.1, and is handling jquery dependency. – Jesper Jensen Jun 05 '15 at 10:25
  • 5
    I think it's a good question, seeing the number of votes it has received, I'm not the only one who thinks that. So you should write an answer to your own question and accept it. It's encouraged on SO. – Emile Bergeron Dec 22 '16 at 02:30

0 Answers0