3

我使用發電機 - 角 - 玉 - 手寫筆在Yeoman上構建了一個應用程序,並且在開發版本中使用grunt serve完美工作,而不是控制檯中的單個錯誤,但在與grunt serve:dist構建應用程序,我的應用程序變成空白頁,並在控制檯以下錯誤:Yeoman generator-angular grunt serve:dist打破我的應用程序

66e3c8ac.vendor.js:4 Uncaught Error: 
Failed to instantiate module monopolyApp due to: 
Error: [$injector:nomod] Module 'monopolyApp' 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.15/$injector/nomod?p0=mon... 
    at http://localhost:9000/scripts/66e3c8ac.vendor.js:4:12729 
    at http://localhost:9000/scripts/66e3c8ac.vendor.js:4:20410 
    at b (http://localhost:9000/scripts/66e3c8ac.vendor.js:4:19993) 
    at http://localhost:9000/scripts/66e3c8ac.vendor.js:4:20305 
    at http://localhost:9000/scripts/66e3c8ac.vendor.js:4:27065 
    at Array.forEach (native) 
    at f (http://localhost:9000/scripts/66e3c8ac.vendor.js:4:13059) 
    at k (http://localhost:9000/scripts/66e3c8ac.vendor.js:4:27005) 
    at Fa (http://localhost:9000/scripts/66e3c8ac.vendor.js:4:28542) 
    at e (http://localhost:9000/scripts/66e3c8ac.vendor.js:4:18649) 

我已經試過

我已經做了相當多的研究在這錯誤,並找到了一些修復,但他們都沒有爲我工作......其中之一m提到useminPrepare會縮小腳本,然後uglify會再次縮小腳本,破壞腳本,並且他們說要從useminPrepare塊中移除uglify來解決它。我試了這個,它給我一個錯誤,它找不到uglify任務,並中止。

我發現了另一個修復程序,說要將<!-- build:js scripts/vendor.js -->更改爲<!-- build:js(app/..) scripts/vendor.js --><!-- build:js(./) scripts/vendor.js --> - 使用此方法從控制檯中刪除了錯誤,但仍留下空白頁。

我有模塊正確地附接至主體body(ng-app="monopolyApp"),這是我的模塊是如何在app.js定義:

angular 
    .module('monopolyApp', [ 
    'ngCookies', 
    'ngResource', 
    'ngSanitize', 
    'ngRoute', 
    'LocalStorageModule' 
    ]) 

,並在控制器(main.js)

angular.module('monopolyApp') 
    .controller('MainCtrl', function ($scope, $window, $timeout, localStorageService) { 

我還在this gist中包含了index.jade,app.js和main.js以供進一步參考。如果需要進一步的信息來診斷這個錯誤,請讓我知道,但我已經嘗試了我可以找到的每一個修復,並沒有任何工作。任何幫助表示讚賞。謝謝!

回答

2

當您使用Yeoman創建應用程序時,它可以在您的Grunt文件和您的bower.json文件中包含模塊名稱。所以,看在你的構建任務Gruntfile.js用於例如爲:

Gruntfile.js: 
    372  dist: { 
    373   options: { 
    374:   module: 'sitesApp', 

改變「sitesApp」到任何你如調用你的角碼的應用'monopolyApp'

+0

我會在下次嘗試,但它似乎是生成器本身而不是我的代碼的問題,因爲當我嘗試使用它啓動您的默認模板發佈應用程序時,它給出了相同的錯誤與...一起。我所做的只是手動將我的手寫筆轉換爲css和jade到html,然後用普通的generator-angular運行它,它工作得很好。我會考慮未來。現在就投入使用,但我會在再次使用發生器並嘗試使用時立即將其標記爲正確答案。謝謝! –

相關問題