2016-12-07 5 views
1

新しいサードパーティ製モジュールが必要な機能を、角型アプリケーションに追加しようとしています。 devモードではすべてうまくいっていますが、私が追加した新しいモジュールは、生産上の悪名高い"Failed to instantiate module"エラーを生成します。私はuglify構築ステップを無効にしようとしましたが、それは何の違いもありませんでした。新しいモジュールを自分自身の依存関係として宣言するだけで、エラーが発生するのです。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 
    }, 

のindex.html:

<!-- 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 
    ]); 

})(); 

JS 縮小さ/ uglified出力:

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", ... 

コンソール出力:

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 
+2

すべての角型プラグインは同じ角型でなければなりません。同じように角型プラグインのバージョンを '1.5.8'にする必要があります私の提案があなたに役立つかどうかわからない、私の側からのその提案 –

+0

@PankajParkarありがとう、私はそれを見落とすことができなかったか、それがなぜ表示されなかったのかわからないdevモードで起動しますが、現在は動作しているようです。 –

+0

あなたがしたい場合、私はそれを答えとして追加することができます、それは他の人にも役立つ可能性があります。 –

答えて

1

を私はあなたを見ることができるように異なる角度の角度を持っていたAPIの読み込みとバインド理想的には、角度APIライブラリを同じバージョンで参照する必要があります。しかしあなたのケースではangular-animateには1.4.8バージョンがありましたが、他の角度APIには1.5.8バージョンがあります。内部的に競合する可能性があります。

むしろ、すべての角APIバージョンを1.5.8と同じにすることをお勧めします。これはあなたの問題を解決する可能性があります。

関連する問題