我最近升级了npm和node,但我的浏览器设置只有一些严重的问题。要求Marionette导致此构建错误,因为Backbone jQuery未定义,因此可能会出现错误。
Uncaught TypeError: Cannot read property 'Deferred' of undefined
以下是我要求Marionette,Backbone和jquery的方式:
var Modernizr = require('Modernizr');
var jQuery = require('jquery');
var Underscore = require('underscore');
var Backbone = require('backbone');
var Moment = require('moment');
Backbone.$ = jQuery;
require('backbone.marionette');
require('backbone.babysitter');
require('backbone.wreqr');
这是我的package.json文件
"devDependencies": {
"backbone": "^1.2.0",
"backbone.babysitter": "^0.1.6",
"backbone.marionette": "^2.4.1",
"backbone.wreqr": "^1.3.1",
"browserify": "^10.2.1",
"browserify-shim": "^3.8.7",
"connect": "^3.3.5",
"d3": "^3.5.5",
"deamdify": "^0.1.1",
"debowerify": "^1.2.1",
"decomponentify": "^0.1.0",
"deglobalify": "^0.2.0",
"event-stream": "^3.3.1",
"font-awesome": "^4.3.0",
"gulp": "^3.8.11",
"gulp-changed": "^1.2.1",
"gulp-clean": "^0.3.1",
"gulp-concat": "^2.5.2",
"gulp-filter": "^2.0.2",
"gulp-flatten": "0.0.4",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.2.1",
"gulp-include": "^1.1.1",
"gulp-livereload": "^3.8.0",
"gulp-minify-css": "^1.1.1",
"gulp-notify": "^2.2.0",
"gulp-open": "^0.3.2",
"gulp-sass": "^2.0.1",
"gulp-streamify": "0.0.5",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.4",
"handlebars": "^3.0.3",
"hbsfy": "^2.2.1",
"imagesloaded": "^3.1.8",
"jquery": "^2.1.4",
"moment": "^2.10.3",
"node-bourbon": "^4.2.2",
"node-sass": "^3.1.2",
"numeral": "^1.5.3",
"spin.js": "^2.1.0",
"underscore": "^1.8.3",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.2.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"browser": {
"Modernizr": "./src/javascript/vendor/modernizr/modernizr.js"
},
"browserify-shim": {
"Modernizr": {
"exports": "Modernizr"
}
},
"browserify": {
"transform": [
"hbsfy",
"debowerify",
"decomponentify",
"deamdify",
"deglobalify",
"browserify-shim"
]
}
我真的不知道是什么导致了这个错误。
答案 0 :(得分:2)
这是Backbone打破Marionette的最新版本的问题。
使用Backbone v1.1.2直到Marionette发布更新应解决它。
以下是参考https://github.com/marionettejs/backbone.marionette/issues/2559
的github问题