TypeError:无法读取undefined的属性'sortingLevel'

时间:2013-10-07 02:37:29

标签: javascript coffeescript marionette bower brunch

样品早午餐会议:

$ npm -v
1.2.25
$ brunch -V
1.7.6
$ bower -v
1.2.7
$ brunch new https://github.com/monokrome/brunch-with-grits.git example
...
$ cd example
$ ls
app  bower_components  bower.json  config.coffee  node_modules  package.json  README.md  vendor
$ ls bower_components/
backbone  backbone.babysitter  backbone.marionette.subrouter  backbone.wreqr  jquery  lodash  marionette  underscore
$ brunch build
06 Oct 22:25:49 - info: compiled 9 files into 3 files, copied index.html in 761ms
$ bower install -S https://github.com/whyohwhyamihere/backbone.marionette.subrouter.git
...
$ grep marionette bower.json
    "marionette": "~1.0.4",
    "backbone.marionette.subrouter": "https://github.com/whyohwhyamihere/backbone.marionette.subrouter.git"
    "marionette": {
      "main": "lib/core/backbone.marionette.js"
$ cp bower.json bower.json.orig
$ vi bower.json
...
$ diff bower.json bower.json.orig
47,52d46
<     }, 
<     "backbone.marionette.subrouter": {
<       "main": "backbone.marionette.subrouter.js",
<       "dependencies": {
<         "marionette": "*"
<       }
$ brunch build
/home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:164
    var level = Math.max(pkg.sortingLevel || 0, initial);
                            ^
TypeError: Cannot read property 'sortingLevel' of undefined
    at setLevel (/home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:164:29)
    at /home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:169:7
    at Array.forEach (native)
    at setLevel (/home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:168:10)
    at Array.forEach (native)
    at setSortingLevels (/home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:175:12)
    at sortPackages (/home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:181:10)
    at /home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:211:20
    at /home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:144:7
    at /home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/async-each/index.js:24:44
    at /home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:101:7
    at /home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/read-components/index.js:49:7
    at fs.js:253:14
    at /home/icyrockcom/nvm/v0.11.3/lib/node_modules/brunch/node_modules/init-skeleton/node_modules/rimraf/node_modules/graceful-fs/graceful-fs.js:103:5
    at Object.oncomplete (fs.js:94:15)

为什么这不起作用的任何想法? marionette包含依赖项,因此不应失败。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,事实证明我在全局和本地安装了brunch。 Aka,我用npm install -g brunch安装了它,并在我的package.json中定义了它。

将其从package.json中删除(或全局卸载),然后重试。