我使用Yeoman构建了一个应用程序,使用generator-angular-jade-stylus,开发版本使用grunt serve
时一切都运行得很完美,在控制台中没有任何错误,但是当我使用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)
我尝试过的方法
我对这个错误进行了相当多的研究,并找到了一些解决方法,但没有一个适用于我...其中一个方法提到useminPrepare会压缩脚本,然后uglify会再次压缩脚本,从而破坏脚本,他们建议从useminPrepare块中删除uglify来解决这个问题。我尝试了这个方法,但只是给了我一个错误,说找不到uglify任务,然后就中止了。
我找到了另一个解决方法,它说要将<!-- build:js scripts/vendor.js -->
更改为<!-- build:js(app/..) scripts/vendor.js -->
或<!-- build:js(./) scripts/vendor.js -->
--使用这种方法可以消除控制台中的错误,但仍然留下了一个空白页面。
我正确地将模块附加到了body标签中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) {
我还在这个 gist中包含了 index.jade、app.js 和 main.js,以供进一步参考。如果需要更多信息来诊断此错误,请告知我,但我已尝试找到的所有修复方法都无效。感谢任何帮助。