Angularjs Angular未能在生产生成中实例化模块

Angularjs Angular未能在生产生成中实例化模块,angularjs,dependency-injection,gulp,bower,angular-module,Angularjs,Dependency Injection,Gulp,Bower,Angular Module,我正在尝试使用gulp和bower向Angular应用程序添加需要新的第三方模块的功能。在开发模式下一切正常,但我添加的任何新模块都会在生产中产生臭名昭著的“未能实例化模块”错误。我尝试过禁用丑陋的构建步骤,但没有任何效果。简单地将新模块声明为我自己模块的依赖项就足以产生错误 与这些问题不同的是,我已经在依赖项中使用了字符串数组语法,并且该应用程序已经与其他各种模块一起运行。我看不出我所添加的和其他已经在使用的库之间有什么区别 下面是我目前尝试加入ngCookies,但我对其他人做了同样的事情,

我正在尝试使用gulp和bower向Angular应用程序添加需要新的第三方模块的功能。在开发模式下一切正常,但我添加的任何新模块都会在生产中产生臭名昭著的
“未能实例化模块”
错误。我尝试过禁用丑陋的构建步骤,但没有任何效果。简单地将新模块声明为我自己模块的依赖项就足以产生错误

与这些问题不同的是,我已经在依赖项中使用了字符串数组语法,并且该应用程序已经与其他各种模块一起运行。我看不出我所添加的和其他已经在使用的库之间有什么区别

下面是我目前尝试加入
ngCookies
,但我对其他人做了同样的事情,例如
ngFileUpload
,结果相同

bower.json:

  "dependencies": {
    "jquery": "^2.1.4",
    "angular": "^1.5.9",
    "angular-sanitize": "^1.4.5",
    "extras.angular.plus": "^0.9.2",
    "moment": "^2.10.3",
    "angular-ui-router": "^0.2.15",
    ...
    "angular-cookies": "^1.5.9", // new
  },
<!-- build:js js/lib.js -->
<!-- bower:js -->
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="/bower_components/extras.angular.plus/ngplus-overlay.js"></script>
<script src="/bower_components/moment/moment.js"></script>
<script src="/bower_components/angular-ui-router/release/angular-ui-router.js"></script>
...
<script src="/bower_components/angular-cookies/angular-cookies.js"></script> // new
<!-- endbower -->
<!-- endbuild -->
(function () {
  'use strict';

  angular
    .module('app.core', [
      'ngAnimate',
      'ngSanitize',
      'blocks.exception',
      'blocks.logger',
      'blocks.router',
      'ui.router',
      'firebase',
      'ngMap',
      'ngplus',
      'ngCookies', // new
    ]);

})();
Error: [$injector:modulerr] Failed to instantiate module app due to:
[$injector:modulerr] Failed to instantiate module app.core due to:
[$injector:modulerr] Failed to instantiate module ngCookies due to:
[$injector:nomod] Module 'ngCookies' 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.5.9/$injector/nomod?p0=ngCookies
index.html:

  "dependencies": {
    "jquery": "^2.1.4",
    "angular": "^1.5.9",
    "angular-sanitize": "^1.4.5",
    "extras.angular.plus": "^0.9.2",
    "moment": "^2.10.3",
    "angular-ui-router": "^0.2.15",
    ...
    "angular-cookies": "^1.5.9", // new
  },
<!-- build:js js/lib.js -->
<!-- bower:js -->
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="/bower_components/extras.angular.plus/ngplus-overlay.js"></script>
<script src="/bower_components/moment/moment.js"></script>
<script src="/bower_components/angular-ui-router/release/angular-ui-router.js"></script>
...
<script src="/bower_components/angular-cookies/angular-cookies.js"></script> // new
<!-- endbower -->
<!-- endbuild -->
(function () {
  'use strict';

  angular
    .module('app.core', [
      'ngAnimate',
      'ngSanitize',
      'blocks.exception',
      'blocks.logger',
      'blocks.router',
      'ui.router',
      'firebase',
      'ngMap',
      'ngplus',
      'ngCookies', // new
    ]);

})();
Error: [$injector:modulerr] Failed to instantiate module app due to:
[$injector:modulerr] Failed to instantiate module app.core due to:
[$injector:modulerr] Failed to instantiate module ngCookies due to:
[$injector:nomod] Module 'ngCookies' 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.5.9/$injector/nomod?p0=ngCookies
缩小/丑陋js输出:

  "dependencies": {
    "jquery": "^2.1.4",
    "angular": "^1.5.9",
    "angular-sanitize": "^1.4.5",
    "extras.angular.plus": "^0.9.2",
    "moment": "^2.10.3",
    "angular-ui-router": "^0.2.15",
    ...
    "angular-cookies": "^1.5.9", // new
  },
<!-- build:js js/lib.js -->
<!-- bower:js -->
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="/bower_components/extras.angular.plus/ngplus-overlay.js"></script>
<script src="/bower_components/moment/moment.js"></script>
<script src="/bower_components/angular-ui-router/release/angular-ui-router.js"></script>
...
<script src="/bower_components/angular-cookies/angular-cookies.js"></script> // new
<!-- endbower -->
<!-- endbuild -->
(function () {
  'use strict';

  angular
    .module('app.core', [
      'ngAnimate',
      'ngSanitize',
      'blocks.exception',
      'blocks.logger',
      'blocks.router',
      'ui.router',
      'firebase',
      'ngMap',
      'ngplus',
      'ngCookies', // new
    ]);

})();
Error: [$injector:modulerr] Failed to instantiate module app due to:
[$injector:modulerr] Failed to instantiate module app.core due to:
[$injector:modulerr] Failed to instantiate module ngCookies due to:
[$injector:nomod] Module 'ngCookies' 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.5.9/$injector/nomod?p0=ngCookies
app.js

function(){"use strict";angular.module("app.core",["ngAnimate","ngSanitize","blocks.exception","blocks.logger","blocks.router","ui.router","firebase","ngMap","ngplus","ngCookies"])}(), ...
lib.js

t.module("ngCookies",["ng"]).provider("$cookies", ... 
控制台输出:

  "dependencies": {
    "jquery": "^2.1.4",
    "angular": "^1.5.9",
    "angular-sanitize": "^1.4.5",
    "extras.angular.plus": "^0.9.2",
    "moment": "^2.10.3",
    "angular-ui-router": "^0.2.15",
    ...
    "angular-cookies": "^1.5.9", // new
  },
<!-- build:js js/lib.js -->
<!-- bower:js -->
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="/bower_components/extras.angular.plus/ngplus-overlay.js"></script>
<script src="/bower_components/moment/moment.js"></script>
<script src="/bower_components/angular-ui-router/release/angular-ui-router.js"></script>
...
<script src="/bower_components/angular-cookies/angular-cookies.js"></script> // new
<!-- endbower -->
<!-- endbuild -->
(function () {
  'use strict';

  angular
    .module('app.core', [
      'ngAnimate',
      'ngSanitize',
      'blocks.exception',
      'blocks.logger',
      'blocks.router',
      'ui.router',
      'firebase',
      'ngMap',
      'ngplus',
      'ngCookies', // new
    ]);

})();
Error: [$injector:modulerr] Failed to instantiate module app due to:
[$injector:modulerr] Failed to instantiate module app.core due to:
[$injector:modulerr] Failed to instantiate module ngCookies due to:
[$injector:nomod] Module 'ngCookies' 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.5.9/$injector/nomod?p0=ngCookies

正如我所看到的,您将不同版本的AngularAPI加载并绑定在一起。理想情况下,您应该参考具有相同版本的angular API库。但在您的例子中,您有
angular animate
,它有
1.4.8
版本,但其他angular API有
1.5.8
版本。这可能会导致内部冲突


相反,我建议您使用与1.5.8相同的所有AngularAPI版本。这可以解决您的问题。

始终确保所有angular插件都应该有相同的angular版本,同样,我可以说您应该有所有angular插件版本都应该是
1.5.8
,因为我可以看到您有angular sanitize版本
1.4.8
,这是不正确的。。我不确定我的建议对你是否有帮助,这是我的建议side@PankajParkar谢谢,我不知道我是怎么忽略了这一点,也不知道为什么它没有在开发模式下出现,但它现在似乎正在工作。如果你想的话,我可以添加它作为答案,也许它也可以帮助其他人。