Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法实例化模块ui.tree,原因是:[$injector:nomod]模块';模块名称';不可用!您可能拼错了模块名称,或者_Javascript_Angularjs_Jasmine - Fatal编程技术网

Javascript 无法实例化模块ui.tree,原因是:[$injector:nomod]模块';模块名称';不可用!您可能拼错了模块名称,或者

Javascript 无法实例化模块ui.tree,原因是:[$injector:nomod]模块';模块名称';不可用!您可能拼错了模块名称,或者,javascript,angularjs,jasmine,Javascript,Angularjs,Jasmine,我正在开发AngularJS应用程序,在该应用程序中,我使用名为的第三方库显示数据。 为了使用这个库,我应该将ui.tree作为依赖项添加到我的主应用程序模块中。为了使用这个库,我已经完成了该链接中给出的所有步骤。 我已经成功地使用这个库创建了我想要的树。现在,我想为我的控制器编写jasmine规范 但是在使用这个库之后,我以前的jasmine规范都不起作用。 所有茉莉花都抛出如下错误 Error: [$injector:modulerr] Failed to instantiate modul

我正在开发AngularJS应用程序,在该应用程序中,我使用名为的第三方库显示数据。
为了使用这个库,我应该将
ui.tree
作为依赖项添加到我的主应用程序模块中。为了使用这个库,我已经完成了该链接中给出的所有步骤。 我已经成功地使用这个库创建了我想要的树。现在,我想为我的控制器编写jasmine规范

但是在使用这个库之后,我以前的jasmine规范都不起作用。
所有茉莉花都抛出如下错误

Error: [$injector:modulerr] Failed to instantiate module CqAdminUiApp due to:
Error: [$injector:modulerr] Failed to instantiate module ui.tree due to:
Error: [$injector:nomod] Module 'ui.tree' 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.8/$injector/nomod?p0=ui.tree
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:68:12
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:2082:17
    at ensure (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:2006:38)
    at module (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:2080:14)
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4617:22
    at forEach (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:321:20)
    at loadModules (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4601:5)
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4618:40
    at forEach (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:321:20)
    at loadModules (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4601:5)
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=ui.tree&p1=Error%3A%20%5B%24injector%3Anomod%5D%20Module%20'ui.tree'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.5.8%2F%24injector%2Fnomod%3Fp0%3Dui.tree%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A68%3A12%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A2082%3A17%0A%20%20%20%20at%20ensure%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A2006%3A38)%0A%20%20%20%20at%20module%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A2080%3A14)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4617%3A22%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A321%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4601%3A5)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4618%3A40%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A321%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4601%3A5)
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:68:12
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4640:15
    at forEach (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:321:20)
    at loadModules (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4601:5)
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4618:40
    at forEach (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:321:20)
    at loadModules (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4601:5)
    at Object.createInjector [as injector] (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4523:19)
    at Object.workFn (http://localhost:8234/webjars/angularjs/1.5.8/angular-mocks.js:3074:52)
    at attemptSync (http://localhost:8234/webjars/jasmine/2.5.1/lib/jasmine-core/jasmine.js:1942:24)
http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=CqAdminUiApp&p1=Error%3A%20%5B%24injector%3Amodulerr%5D%20Failed%20to%20instantiate%20module%20ui.tree%20due%20to%3A%0AError%3A%20%5B%24injector%3Anomod%5D%20Module%20'ui.tree'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.5.8%2F%24injector%2Fnomod%3Fp0%3Dui.tree%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A68%3A12%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A2082%3A17%0A%20%20%20%20at%20ensure%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A2006%3A38)%0A%20%20%20%20at%20module%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A2080%3A14)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4617%3A22%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A321%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4601%3A5)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4618%3A40%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A321%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4601%3A5)%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.5.8%2F%24injector%2Fmodulerr%3Fp0%3Dui.tree%26p1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520Module%2520'ui.tree'%2520is%2520not%2520available!%2520You%2520either%2520misspelled%2520the%2520module%2520name%2520or%2520forgot%2520to%2520load%2520it.%2520If%2520registering%2520a%2520module%2520ensure%2520that%2520you%2520specify%2520the%2520dependencies%2520as%2520the%2520second%2520argument.%250Ahttp%253A%252F%252Ferrors.angularjs.org%252F1.5.8%252F%2524injector%252Fnomod%253Fp0%253Dui.tree%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A68%253A12%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A2082%253A17%250A%2520%2520%2520%2520at%2520ensure%2520(http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A2006%253A38)%250A%2520%2520%2520%2520at%2520module%2520(http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A2080%253A14)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A4617%253A22%250A%2520%2520%2520%2520at%2520forEach%2520(http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A321%253A20)%250A%2520%2520%2520%2520at%2520loadModules%2520(http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A4601%253A5)%250A%2520%2520%2520%2520at%2520http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A4618%253A40%250A%2520%2520%2520%2520at%2520forEach%2520(http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A321%253A20)%250A%2520%2520%2520%2520at%2520loadModules%2520(http%253A%252F%252Flocalhost%253A8234%252Fwebjars%252Fangularjs%252F1.5.8%252Fangular.js%253A4601%253A5)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A68%3A12%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4640%3A15%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A321%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4601%3A5)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4618%3A40%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A321%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4601%3A5)%0A%20%20%20%20at%20Object.createInjector%20%5Bas%20injector%5D%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular.js%3A4523%3A19)%0A%20%20%20%20at%20Object.workFn%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fangularjs%2F1.5.8%2Fangular-mocks.js%3A3074%3A52)%0A%20%20%20%20at%20attemptSync%20(http%3A%2F%2Flocalhost%3A8234%2Fwebjars%2Fjasmine%2F2.5.1%2Flib%2Fjasmine-core%2Fjasmine.js%3A1942%3A24)
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:68:12
    at http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4640:15
    at forEach (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:321:20)
    at loadModules (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4601:5)
    at Object.createInjector [as injector] (http://localhost:8234/webjars/angularjs/1.5.8/angular.js:4523:19)
    at Object.workFn (http://localhost:8234/webjars/angularjs/1.5.8/angular-mocks.js:3074:52)
    at attemptSync (http://localhost:8234/webjars/jasmine/2.5.1/lib/jasmine-core/jasmine.js:1942:24)
    at QueueRunner.run (http://localhost:8234/webjars/jasmine/2.5.1/lib/jasmine-core/jasmine.js:1930:9)
    at QueueRunner.execute (http://localhost:8234/webjars/jasmine/2.5.1/lib/jasmine-core/jasmine.js:1915:10)
    at Spec.queueRunnerFactory (http://localhost:8234/webjars/jasmine/2.5.1/lib/jasmine-core/jasmine.js:710:35)
CqAdminUiApp routing should proceed to /Jobs on requests to /Jobs when logged in 
前几行表示模块
ui.tree
可能未作为依赖项添加到主应用程序模块。但我已经确保它被添加。 我在stackoverflow上找到了关于此错误的其他帖子,但所有帖子都谈到了将缺少的模块作为依赖项添加到主应用程序中,我已经这样做了。
我很惊讶我仍然会犯同样的错误。
Blow是代码片段

我的主应用程序模块

(function () {
'use strict';
var MyUiApp = angular.module('MyUiApp', [
    'ngRoute',
    'ngAnimate',
    'ngCookies',
    'ui.bootstrap',
    'ui.tree',
    'chart.js',
]);

MyApp.config(['$routeProvider', function ($routeProvider) {
    $routeProvider.
    when('/Authenticate', {
        templateUrl: 'app/views/authenticate.html',
        controller: 'authenticationController'
    }).

    // configuration for other urls.
   }]);
}()); 
// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html
'use strict';

// ...
module.exports = function(config) {
    config.set({
        // base path, that will be used to resolve files and exclude
        basePath: '../../..',

        // testing framework to use (jasmine/mocha/qunit/...)
        frameworks: ['jasmine'],

        // list of files / patterns to load in the browser
        files: [
               'src/main/resources/webapp/lib/jquery/jquery.js',
               'src/main/resources/webapp/lib/angular/angular.js',

                // !!! This was missing:
               'src/main/resources/webapp/lib/angular-ui-tree/dist/angular-ui-tree.js'

               'src/main/resources/webapp/app/*.js',
               'src/main/resources/webapp/app/**/*.js',
        ],
        ...
    });
};
index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="ISO-8859-1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/png" href="assets/image/favicon.png"/>
    <link rel="stylesheet" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="webjars/bootstrap/3.3.7/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="webjars/angular-chart.js/0.8.8/angular-chart.css">
    <link rel="stylesheet" href="webjars/angular-ui-grid/3.2.1/ui-grid.min.css">
    <link rel="stylesheet" href="assets/css/derp.css">
    <link rel="stylesheet" href="assets/css/spinner.css">
    <link rel="stylesheet" href="assets/css/blur.css">
    <link rel="stylesheet" href="assets/css/angular-ui-tree.min.css">   

    <script src="webjars/angularjs/1.5.8/angular.min.js"></script>
    <script src="webjars/angularjs/1.5.8/angular-route.min.js"></script>
    <script src="webjars/angularjs/1.5.8/angular-animate.min.js"></script>
    <script src="webjars/angularjs/1.5.8/angular-cookies.min.js"></script>
    <script src="webjars/angular-base64/2.0.5/angular-base64.min.js"></script>
    <script src="webjars/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.min.js"></script>
    <script src="webjars/favico.js/0.3.10/favico-0.3.10.min.js"></script>
    <script src="webjars/chartjs/2.1.3/Chart.min.js"></script>
    <script src="webjars/angular-chart.js/0.8.8/angular-chart.min.js"></script>
    <script src="webjars/angular-ui-grid/3.2.1/ui-grid.min.js"></script>
    <script src="assets/js/angular-ui-tree.js"></script>    // This js file is required for ui-tree
    //Other files

</head>
<body ng-app="CqAdminUiApp">
    <div ng-controller="indexController">
        <div id="wrapper">
            <div id="sidebar-wrapper">
                <ul class="sidebar-nav">
                    <li class="sidebar-brand">Continuous Quality</li>
                    <li><a href="#link1">link1</a></li>
                    <li><a href="#link2">Link2</a></li>
                    <li><a href="#link3">Link3</a></li>
                    <li><a href="#link4">Link4</a></li
                    <li><a href="#Logout">* Logout *</a></li>
                </ul>
            </div>
            <div id="page-content-wrapper">
                <div ng-view class="explode-animation"></div>
            </div>
        </div>
    </div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Derp-o-meter v1.0</title>

<link rel="shortcut icon" type="image/png" href="assets/image/favicon.png">
<link rel="stylesheet" href="../webjars/jasmine/2.5.1/lib/jasmine-core/jasmine.css">

<script src="../webjars/jasmine/2.5.1/lib/jasmine-core/jasmine.js"></script>
<script src="../webjars/jasmine/2.5.1/lib/jasmine-core/jasmine-html.js"></script>
<script src="../webjars/jasmine/2.5.1/lib/jasmine-core/boot.js"></script>

<script src="../webjars/angularjs/1.5.8/angular.js"></script>
<script src="../webjars/angularjs/1.5.8/angular-mocks.js"></script>
<script src="../webjars/angularjs/1.5.8/angular-route.js"></script>
<script src="../webjars/angularjs/1.5.8/angular-animate.js"></script>
<script src="../webjars/angular-base64/2.0.5/angular-base64.js"></script>
<script src="../webjars/angularjs/1.5.8/angular-cookies.min.js"></script>
<script src="../webjars/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.min.js"></script>
<script src="../webjars/favico.js/0.3.10/favico-0.3.10.min.js" ></script>
<script src="../webjars/chartjs/2.1.3/Chart.min.js"></script>
<script src="../webjars/angular-chart.js/0.8.8/angular-chart.min.js"></script>
<script src="../webjars/angular-ui-grid/3.2.1/ui-grid.min.js"></script>
<script src="../assets/js/angular-ui-tree.js"></script>           // This is the js file needed for ui-tree

<!-- include source files here... -->
<script src="../app/services/authenticationService.js"></script>
<script src="../app/services/eventsService.js"></script>
<script src="../app/controllers/eventsController.js"></script>
<script src="../app/controllers/indexController.js"></script>
<!-- include spec files here... -->

<script src="spec/controllers/eventsController-spec.js"></script>
<script src="spec/controllers/jobsController-spec.js"></script>
// other spec files

<body>
</body>
</html>

有人能帮我摆脱上面描述的错误吗。

我遇到了完全相同的问题,我的问题与karma.conf.js中缺少依赖项有关:

(function () {
'use strict';
var MyUiApp = angular.module('MyUiApp', [
    'ngRoute',
    'ngAnimate',
    'ngCookies',
    'ui.bootstrap',
    'ui.tree',
    'chart.js',
]);

MyApp.config(['$routeProvider', function ($routeProvider) {
    $routeProvider.
    when('/Authenticate', {
        templateUrl: 'app/views/authenticate.html',
        controller: 'authenticationController'
    }).

    // configuration for other urls.
   }]);
}()); 
// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html
'use strict';

// ...
module.exports = function(config) {
    config.set({
        // base path, that will be used to resolve files and exclude
        basePath: '../../..',

        // testing framework to use (jasmine/mocha/qunit/...)
        frameworks: ['jasmine'],

        // list of files / patterns to load in the browser
        files: [
               'src/main/resources/webapp/lib/jquery/jquery.js',
               'src/main/resources/webapp/lib/angular/angular.js',

                // !!! This was missing:
               'src/main/resources/webapp/lib/angular-ui-tree/dist/angular-ui-tree.js'

               'src/main/resources/webapp/app/*.js',
               'src/main/resources/webapp/app/**/*.js',
        ],
        ...
    });
};

我有完全相同的问题,我的问题与karma.conf.js中缺少依赖性有关:

(function () {
'use strict';
var MyUiApp = angular.module('MyUiApp', [
    'ngRoute',
    'ngAnimate',
    'ngCookies',
    'ui.bootstrap',
    'ui.tree',
    'chart.js',
]);

MyApp.config(['$routeProvider', function ($routeProvider) {
    $routeProvider.
    when('/Authenticate', {
        templateUrl: 'app/views/authenticate.html',
        controller: 'authenticationController'
    }).

    // configuration for other urls.
   }]);
}()); 
// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html
'use strict';

// ...
module.exports = function(config) {
    config.set({
        // base path, that will be used to resolve files and exclude
        basePath: '../../..',

        // testing framework to use (jasmine/mocha/qunit/...)
        frameworks: ['jasmine'],

        // list of files / patterns to load in the browser
        files: [
               'src/main/resources/webapp/lib/jquery/jquery.js',
               'src/main/resources/webapp/lib/angular/angular.js',

                // !!! This was missing:
               'src/main/resources/webapp/lib/angular-ui-tree/dist/angular-ui-tree.js'

               'src/main/resources/webapp/app/*.js',
               'src/main/resources/webapp/app/**/*.js',
        ],
        ...
    });
};

您能否共享spec.js文件(尝试只运行其中一个,并共享该文件)我添加了一个spec.js文件。不完全确定,但您能否在spec开头添加“beforeach(module('MyUiApp');”,以确保模块已加载?值得一试。我按照你的建议试了。但是仍然会出现相同的错误。是否确实在spec-runner.html中包含了所有源文件(包括定义主应用程序模块的源文件)?我不确定我是否看到它们(只有控制器/服务在那里)你能共享spec.js文件吗(尝试只运行其中一个,并共享该文件)我添加了一个spec.js文件。不完全确定,但你能在spec的开头添加“beforeach(module('MyUiApp');”以确保模块已加载吗?值得一试。我按照你的建议试了。但是仍然会出现相同的错误。是否确实在spec-runner.html中包含了所有源文件(包括定义主应用程序模块的源文件)?我不确定我是否看到它们(只有控制器/服务在那里)