简体   繁体   English

Karma的“没有提供商错误”服务运行angularjs phonecat教程

[英]“No provider error” on Karma serve running angularjs phonecat tutorial

I have found and tried many solutions offered here and elsewhere: re downgrading karma version upgrading node and npm - changing order of load in the config file.... but so far nothing works. 我已经找到并尝试了在这里和其他地方提供的许多解决方案:重新降级业力版本升级节点和npm - 改变配置文件中的加载顺序....但到目前为止没有任何作用。 Is the problem that I am running the angular tutorial via Apache? 我是通过Apache运行角度教程的问题吗?

Starting Karma Server ( http://karma-runner.github.io ) 启动Karma Server( http://karma-runner.github.io

/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
            ^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
    at error (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at /usr/local/lib/node_modules/karma/lib/server.js:28:14
    at Array.forEach (native)
    at start (/usr/local/lib/node_modules/karma/lib/server.js:27:21)
    at invoke (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (/usr/local/lib/node_modules/karma/lib/server.js:204:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/karma/bin/karma
/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
            ^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
    at error (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at /usr/local/lib/node_modules/karma/lib/server.js:28:14
    at Array.forEach (native)
    at start (/usr/local/lib/node_modules/karma/lib/server.js:27:21)
    at invoke (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (/usr/local/lib/node_modules/karma/lib/server.js:204:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/karma/bin/karma:19:39)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

你必须安装茉莉花:

    npm install -g karma-jasmine

The selected answer didn´t work for me, this is what it work for me: 选定的答案对我不起作用,这对我有用:

https://github.com/karma-runner/karma/issues/880 https://github.com/karma-runner/karma/issues/880

Karma needs to load the plugins (such as karma-jasmine). Karma需要加载插件(例如karma-jasmine)。 By default (if you don't specify config.plugins), Karma loads all the karma-* modules that are siblings to Karma. 默认情况下(如果你没有指定config.plugins),Karma将所有作为兄弟姐妹的karma- *模块加载到Karma。

It sounds like you have Karma installed globally (npm install -g karma) and jasmine plugin locally (npm install karma-jasmine). 听起来你全局安装了Karma(npm install -g karma)和本地jasmine插件(npm install karma-jasmine)。 If that's the case, install Karma locally. 如果是这种情况,请在本地安装Karma。

The recomended way is to install Karma and all the plugins locally, per project. 推荐的方法是在每个项目中在本地安装Karma和所有插件。

as per the documentation following plugins are required. 根据以下插件的文档是必需的。 // these plugins will be require() by Karma 'karma-jasmine', 'karma-chrome-launcher' //这些插件将由Karma'karma-jasmine','karma-chrome-launcher'命令()

So add these two to your plugin section. 所以将这两个添加到您的插件部分。

I don't know what platform/os/version you're on, but for me, on mac os x 10.9 ("Mavericks"), I was running into the exact same issue with trying to run karma on an e2e test with the simple angular docs tutorial in their step 3. I solved it in a pretty silly/dumb way => 我不知道你在使用什么平台/操作系统/版本,但对我来说,在mac os x 10.9(“Mavericks”)上,我遇到了同样的问题,试图在e2e测试中运行karma他们在第3步中使用了简单的角度文档教程。我以一种非常愚蠢/愚蠢的方式解决了它=>

  1. Closed the terminal/shell window in which I had all these problems 关闭了我遇到所有这些问题的终端/ shell窗口
  2. Re-opened a new terminal/shell window 重新打开一个新的终端/ shell窗口
  3. Ran everything with sudo in front 在前面用sudo跑一切

It all installed/worked, including... npm install -g . 它全部安装/工作,包括... npm install -g

so there you go. 你去吧

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM