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条回答
Deceive 欺骗
2楼-- · 2019-02-05 10:44

Here is the primary bug request on github https://github.com/yeoman/generator-angular/issues/629

According to this, the problem is more with the karma-generator in which used to contain these 2 extensions by default and no longer do.

查看更多
Animai°情兽
3楼-- · 2019-02-05 10:44

npm i -D @types/es6-promise @types/es6-collections

查看更多
▲ chillily
4楼-- · 2019-02-05 10:46

for me I didn't have the karma client installed globally.

npm install -g karma-cli

查看更多
劫难
5楼-- · 2019-02-05 10:47

I struggled with the exact same problem. After investigating I realized that karma was running globally using '/usr/' directory as the base folder.

A solution that worked for me was to replace karma with karma-cli:

npm remove -g karma
npm install -g karma-cli
查看更多
看我几分像从前
6楼-- · 2019-02-05 10:47

For those of you using karma-spec-reporter and getting this error: "Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)"

In your karma.conf.js, remove: "plugins: ["karma-spec-reporter"]" and the error should go away.

查看更多
走好不送
7楼-- · 2019-02-05 10:51

Grunt --force works because you tell it to bypass the karma tests. Notice if you run grunt --force, it'll still say "Done, but with warnings".

To fix: add "karma-jasmine" and "karma-chrome-launcher" (or whatever launcher you use) to the devDependencies in packages.json and run npm install again.

npm install karma-jasmine --save-dev

npm install karma-chrome-launcher --save-dev

This will save karma-jasmine and karma-chrome-launcher in your project's package.json file. The packages can then be installed by running:

npm install

Source: No provider for "framework:jasmine"! (Resolving: framework:jasmine)

查看更多
登录 后发表回答