简体   繁体   English

Angular / Karma:错误:[$ injector:nomod]模块'模块'不可用

[英]Angular/Karma: Error: [$injector:nomod] Module 'module' is not available

So I'm trying to use the Karma test runner on my Angular project, but I keep getting this error: 所以我试图在我的Angular项目中使用Karma测试运行器,但我一直收到这个错误:

Error: [$injector:nomod] Module 'app.auth' is not available! 错误:[$ injector:nomod]模块'app.auth'不可用! 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. 如果注册模块,请确保将依赖项指定为第二个参数。

I have all my .js files in a scripts folder, that my karma.conf.js is pointing to, but for some reason I keep getting that error. 我在脚本文件夹中有我的所有.js文件,我的karma.conf.js指向,但由于某种原因,我不断收到该错误。

My karma.conf.js file looks like this: 我的karma.conf.js文件如下所示:

module.exports = function(config) {
  config.set({
    basePath: '.',
    frameworks: ['mocha'],
    files: [
      '../bower_components/angular/angular.js',
      '../bower_components/jquery/dist/jquery.js',
      '../bower_components/angular-mocks/angular-mocks.js',
      '../scripts/app.module.js',
      '../scripts/**/*.js',
      './unit/*.js'
    ],
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    concurrency: Infinity
  })
}

Does anyone have an idea of what might be causing this issue? 有没有人知道可能导致这个问题的原因?

Any help is appreciated. 任何帮助表示赞赏。 Thanks in advance! 提前致谢!

Could you please provide the spec that you are trying to run. 你能提供你想要运行的规范吗? Generally this error occurs when respective module is not loaded in the spec. 通常,在规范中未加载相应模块时会发生此错误。

Try loading the angular module in a beforeEach block 尝试在beforeEach块中加载角度模块

    beforeEach(angular.mock.module('app.auth'));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:[$ injector:nomod]模块不可用 - Error: [$injector:nomod] Module is not available Angular JS错误:[$ injector:nomod]模块'portfolioMockupApp.services'不可用 - Angular JS Error: [$injector:nomod] Module 'portfolioMockupApp.services' is not available 错误:[$ injector:nomod]模块“ nvd3”不可用 - Error: [$injector:nomod] Module 'nvd3' is not available 单元测试AngularJS:未捕获错误:[$ injector:nomod]模块不可用! 和ReferenceError:运行Karma时未定义模块 - Unit-Testing AngularJS: Uncaught Error: [$injector:nomod] Module is not available! and ReferenceError: module is not defined when run Karma AngularJS:未捕获的错误:[$injector:nomod] 模块 _ 不可用! | 对模块的多次引用 - AngularJS: Uncaught Error: [$injector:nomod] Module _ is not available! | Multiple References to Module Angular.JS:由于以下原因而无法实例化模块路由:错误:$ injector:nomod模块“路由”不可用 - Angular.JS: Failed to instantiate module routing due to: Error: $injector:nomod Module 'routing' is not available “错误:$ injector:nomod模块不可用” - “Error: $injector:nomod Module Unavailable” Angular JS,错误:[$ injector:nomod]模块'blogger.posts.controllers'不可用 - Angular JS, Error: [$injector:nomod] Module 'blogger.posts.controllers' is not available Ja茉莉角错误:[$ injector:nomod] - Karma Jasmine Angular Error: [$injector:nomod] `[$$ jector:nomod]模块“ google-maps”不可用。 - `[$injector:nomod] Module 'google-maps' is not available`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM