最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Warning: Task "karma" not found. Use --force to continue - Stack Overflow

programmeradmin0浏览0评论

I've generated an AngularJS project by using Yeoman by running

yo Angular myProjectName

And I then ran

grunt

to build the project. But then the build got abborted because of warnings:

Deans-MacBook-Air:frontend dean$ grunt
Running "newer:jshint" (newer) task

Running "newer:jshint:all" (newer) task

Running "jshint:all" (jshint) task

✔ No problems


Running "newer-postrun:jshint:all:1:/Users/dean/Desktop/myProjectName/frontend/node_modules/grunt-newer/.cache" (newer-postrun) task

Running "newer:jshint:test" (newer) task
No newer files to process.
Warning: Task "karma" not found. Use --force to continue.

Aborted due to warnings.


Execution Time (2014-07-18 07:37:37 UTC)
loading tasks                    3ms  ▇ 3%
newer:jshint                     3ms  ▇ 3%
newer:jshint:all                 6ms  ▇▇ 6%
jshint:all                      75ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 79%
newer-postrun:...-newer/.cache   1ms  ▇ 1%
newer:jshint:test                5ms  ▇▇ 5%
Total 95ms
Deans-MacBook-Air:frontend dean$ 

So yeah... I tried running

npm install -g generator-karma

and then restarting my terminal after it installed but that didn't work either. I'm using a macbook running OSX 10.9.4 fyi.

I've generated an AngularJS project by using Yeoman by running

yo Angular myProjectName

And I then ran

grunt

to build the project. But then the build got abborted because of warnings:

Deans-MacBook-Air:frontend dean$ grunt
Running "newer:jshint" (newer) task

Running "newer:jshint:all" (newer) task

Running "jshint:all" (jshint) task

✔ No problems


Running "newer-postrun:jshint:all:1:/Users/dean/Desktop/myProjectName/frontend/node_modules/grunt-newer/.cache" (newer-postrun) task

Running "newer:jshint:test" (newer) task
No newer files to process.
Warning: Task "karma" not found. Use --force to continue.

Aborted due to warnings.


Execution Time (2014-07-18 07:37:37 UTC)
loading tasks                    3ms  ▇ 3%
newer:jshint                     3ms  ▇ 3%
newer:jshint:all                 6ms  ▇▇ 6%
jshint:all                      75ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 79%
newer-postrun:...-newer/.cache   1ms  ▇ 1%
newer:jshint:test                5ms  ▇▇ 5%
Total 95ms
Deans-MacBook-Air:frontend dean$ 

So yeah... I tried running

npm install -g generator-karma

and then restarting my terminal after it installed but that didn't work either. I'm using a macbook running OSX 10.9.4 fyi.

Share Improve this question asked Jul 18, 2014 at 7:46 user818700user818700 8
  • 1 Did you also tried npm install -g karma – Dayde Commented Jul 18, 2014 at 8:07
  • 1 @Dayde - I tried that just now, didn't work either though. – user818700 Commented Jul 18, 2014 at 8:11
  • 3 I found another thread on a very similar issue. If this doesn't could you please post your node & npm version and the generated package.json and Gruntfile.js? – Dayde Commented Jul 18, 2014 at 9:12
  • 2 @Dayde - holy crap it worked! Thanks! (Running 'sudo npm install grunt-karma --save-dev' that is...) – user818700 Commented Jul 18, 2014 at 9:19
  • 1 You're wele :-) I didn't think the save-dev option would have change something in the first place but after reading a bit more carefully it makes sense : it forces grunt to register the task because it now appears in the file package.json. – Dayde Commented Jul 18, 2014 at 10:25
 |  Show 3 more ments

2 Answers 2

Reset to default 6
sudo npm install grunt-karma --save-dev

The only solution for me that work is:

sudo npm install grunt-karma karma karma-phantomjs-launcher karma-jasmine jasmine-core phantomjs-prebuilt --save-dev

grunt test or: grunt serve, it's work !

发布评论

评论列表(0)

  1. 暂无评论