Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backbone Marionette and Webpack - Uncaught TypeError: Cannot read property 'radio' of undefined

I recently did an npm install on my webpack/backbone/marionette project and everything broke. I now keep getting this error when I application runs:

Uncaught TypeError: Cannot read property 'radio' of undefined

backbone.marionette.js line 3328

this.channel = _.result(this, 'channel') || Backbone.Wreqr.radio.channel(this.channelName);

Backbone: 1.2.3 (I also tried the brand new version from today of 1.3.1)

Marionette: 2.4.4

Webpack: 1.12.14

I thankfully had a backup of my old node_modules and noticed this difference in the marionette library folder structure.

enter image description here

Any idea what's going on? I hadn't touched my package.json I just re-ran npm install with what it seems like a new version of npm/node.

UPDATE I found this thread where at least one person had the exact same issue but I still don't have a solution https://github.com/marionettejs/backbone.marionette/issues/2559

like image 862
user391986 Avatar asked Sep 25 '22 04:09

user391986


2 Answers

I solved this problem by add a alias in my webpack configure file.

alias: {
    backbone: path.join(__dirname, 'node_modules', 'backbone', 'backbone')
}

I noticed that webpack packs multiple copy of backbone.js in its output file if without alias.

like image 172
zcodes Avatar answered Oct 20 '22 15:10

zcodes


Helped to set deps in package.json to:

 "dependencies": {
    "backbone.marionette": "^2.4.4",
    "jquery": "^2.2.1",
    "underscore": "^1.8.3"
  }

(removed backbone dep completely)

like image 31
lanwen Avatar answered Oct 20 '22 16:10

lanwen