Cannot find module 'karma' while using grunt

TeknasVaruas picture TeknasVaruas · Oct 5, 2013 · Viewed 30.8k times · Source

I am using Yeoman toolkit to bootstrap an Angular web application. I've followed all the steps mentioned here. But still, apparently, grunt can not find the karma module. It spits out this error:

Loading "grunt-karma.js" tasks...ERROR
>> Error: Cannot find module 'karma'
Warning: Task "karma" not found. Use --force to continue.

Aborted due to warnings.

I've tried installing karma both locally and globally using npm, but nothing seems to work.

Answer

Stuart picture Stuart · Oct 6, 2013

Make sure you have installed both karma and grunt-karma before running the grunt task:

npm install karma
npm install grunt-karma

EDIT: One liner:

npm install karma grunt-karma