Grunt构建破坏了我编译的javascript

时间:2015-08-23 09:06:36

标签: javascript ruby-on-rails angularjs node.js gruntjs

我有一个从一开始就没有开采的项目,整个部署都不完整。我有一个怪异的咕噜声忽略指定here的覆盖,现在我发现当他生成带有所有依赖关系的 vendor.js 时,它根本不起作用。浏览器打印:

    Uncaught TypeError: Cannot read property 'Item' of undefined(anonymous function) @ vendor.js:14(anonymous function) @ vendor.js:14
vendor.js:4 Uncaught Error: [$injector:nomod] Module 'gettext' 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.2.14/$injector/nomod?p0=gettext(anonymous function) @ vendor.js:4(anonymous function) @ vendor.js:4b @ vendor.js:4l.bootstrap @ vendor.js:4(anonymous function) @ scripts.js:1
VM47 vendor.js:4 Uncaught Error: [$injector:modulerr] Failed to instantiate module trepeatApp due to:
Error: [$injector:modulerr] Failed to instantiate module angularPayments due to:
Error: [$injector:nomod] Module 'angularPayments' 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.

当我只使用 grunt serve 任务时,它运行正常但是如果我 grunt build 这些任务中的某些东西,只需打破怪异的脚本

    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'usemin',
    'htmlmin',

有人能帮助我吗?我非常绝望

[更新 - 2015年8月24日] 我已经阅读了@RobSchmuecker评论的链接并更改了gettext配置上的一些内容,其中一个错误已经解决。

Uncaught Error: [$injector:modulerr] Failed to instantiate module trepeatApp due to:
Error: [$injector:modulerr] Failed to instantiate module angularPayments due to:
Error: [$injector:nomod] Module 'angularPayments' 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.4.4/$injector/nomod?p0=angularPayments
    at http://mylocaldev.com:3000/scripts/vendor.js:4:15152
    at http://mylocaldev.com:3000/scripts/vendor.js:4:24650
    at b (http://mylocaldev.com:3000/scripts/vendor.js:4:24123)
    at http://mylocaldev.com:3000/scripts/vendor.js:4:24435
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1222
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1169
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
http://errors.angularjs.org/1.4.4/$injector/modulerr?p0=angularPayments&p1=…20n%20(http%3A%2F%2Fmylocaldev.com%3A3000%2Fscripts%2Fvendor.js%3A5%3A1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:4:15152
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1428
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at http://mylocaldev.com:3000/scripts/vendor.js:5:1169
    at f (http://mylocaldev.com:3000/scripts/vendor.js:4:15559)
    at n (http://mylocaldev.com:3000/scripts/vendor.js:5:1000)
    at $a (http://mylocaldev.com:3000/scripts/vendor.js:5:2690)
    at h (http://mylocaldev.com:3000/scripts/vendor.js:4:22195)
    at ga (http://mylocaldev.com:3000/scripts/vendor.js:4:22505)
http://errors.angularjs.org/1.4.4/$injector/modulerr?p0=trepeatApp&p1=Error…ga%20(http%3A%2F%2Fmylocaldev.com%3A3000%2Fscripts%2Fvendor.js%3A4%3A22505)

2 个答案:

答案 0 :(得分:1)

发现当我跑grunt serve时,一切都会正常工作,但是当我编译,缩小和其他一切这个错误

Uncaught TypeError: Cannot read property 'Item' of undefined(anonymous function) @ vendor.js:14(anonymous function) @ vendor.js:14

实际上会妨碍角度的正常运作。导致此问题是因为需要在outlayer文件上覆盖异常bower.json,以便在item.js之前加载outlayer.js,并且由于某种未知原因,覆盖选项为不适合我。我必须从我的outlayer中移除bower.json,并在将所有内容加载到角上后手动将其包含在索引中。

答案 1 :(得分:0)

正如jesus.jackson.sena所说,这个错误可能是由Outlayer造成的。但与他相比,覆盖对我来说效果很好。因此,作为需要它的人的参考,那就是如何在bower.json中正确设置覆盖:

"overrides": {
  "outlayer": {
    "main": [
      "item.js",
      "outlayer.js"
    ]
  }
}

对于那些对此行为感兴趣的人: outlayer.js具有以下初始化代码:

window.Outlayer = factory(
  window,
  window.EvEmitter,
  window.getSize,
  window.fizzyUIUtils,
  window.Outlayer.Item
);

对于要定义的window.Outlayer.Item,必须首先调用Outlayer的item.js,它定义如下:

window.Outlayer = {};
window.Outlayer.Item = factory(
  window.EvEmitter,
  window.getSize
);