【问题标题】:Grunt build is breaking my compiled javascriptGrunt build 正在破坏我编译的 javascript
【发布时间】:2015-11-16 20:26:57
【问题描述】:

我有一个从一开始就不是我的项目,整个部署是不完整的。我有可怕的咕噜声,忽略了指定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)

【问题讨论】:

  • 它会为您提供错误详细信息,因此请检查Itemgettext 的使用情况,它们是如何注入的,缩小是否安全等。
  • 您可能没有正确定义和注入 angularPayments 模块以允许压缩程序正确引用它。看看这里docs.angularjs.org/guide/di
  • 我已经知道是什么导致了Item,咕噜忽略了指定的覆盖,就像我在问题@dfsq 上所说的那样
  • 我将检查该链接@RobSchmuecker。谢谢

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


【解决方案1】:

发现当我运行 grunt serve 时一切正常,但是当我编译、缩小和其他所有内容时出现此错误

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

实际上会阻止角度的正常运行。之所以会出现此问题,是因为需要在bower.json 文件上覆盖该死的outlayer,以便在outlayer.js 之前加载item.js,并且由于某种未知原因,覆盖选项对我不起作用。我不得不从我的bower.json 中删除outlayer,并在所有内容都加载到角度后手动将其包含在索引中。

【讨论】:

    【解决方案2】:

    正如 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
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-09
      • 2016-07-02
      • 2017-12-21
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多