Error: No provider for “framework:jasmine”! (Resol

2019-02-05 10:44发布

I have run on my windows console:

npm install -g yo grunt-cli bower

npm install -g generator-angular

yo angular

Then I started my project with webstorm and did right click on the karma.conf.js file in the project explorer where I have the menu item 'Run karma.conf.js' and start the karma runner. Then I get his exception:

...\app\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)

Then in the console I read I can also use --force so I tried it: grunt --force

It took some time but there seemed to be no more errors. Heck why does --force install a provider ??? THIS was TESTED in the CMD.

grunt serve now worked and it started my browser with the starting app.

So what was --force doing that the 'Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)' is gone ?

When I do grunt in the webstrom IDE I get again:

Warning: No provider for "framework:jasmine"! (Resolving: framework:jasmine) Use --force to continue.

So this problem is not solved.

9条回答
家丑人穷心不美
2楼-- · 2019-02-05 10:56

And for me, I didn't have the karma-jasmine globally.

npm install -g karma-jasmine

as described here: "No provider error" on Karma serve running angularjs phonecat tutorial

查看更多
聊天终结者
3楼-- · 2019-02-05 11:01

Adding a reply in case if someone still gets this error.

Karma-cli (karma start) will give Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine) for one of the following reasons:

  1. You have not yet installed karma-jasmine node module and its not listed in devDependencies section in your package.json

Solution: npm install -D karma-jasmine

  1. You have a 'plugins' property array in your karma.config.js file, but this array has no mention of 'karma-jasmine'.

Solution: Add 'karma-jasmine' to plugins in karma.config.js or get rid of this whole 'plugins' property if possible.

plugins:['karma-jasmine']

  1. You have a global install of 'karma-cli' and when you do 'karma start', karma is trying to find the karma-jasmine module in global scope. Check global installed modules list using: npm list -g --depth=0.

Solution: Either install karma-jasmine also in global scope using 'npm install -g karma-jasmine' or remove karma from global scope and install it in local project scope. In later case you will have to add following to package.json:

"scripts" { 
 "test": "karma start"
}

and run karma using command 'npm run test' or 'npm test'.

查看更多
地球回转人心会变
4楼-- · 2019-02-05 11:02

And for those who are still new enough to Karma (like me), don't forget to make sure you've added the plugin to your karma.conf.js file. Finally occurred to me after running through most of these other proposed fixes : (

module.exports = function (config) {
  config.set({
    basePath: '',

    plugins: [
      'karma-chrome-launcher',
      'karma-jasmine'
    ],
...

Hope this helps someone out there, even though this question is now pretty ancient and doesn't seem the originator is still monitoring it ; )

查看更多
登录 后发表回答