使用grunt时无法找到模块“karma”

时间:2021-06-25 19:43:50

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:

我正在使用Yeoman toolkit引导一个有棱角的web应用程序。我已经完成了这里提到的所有步骤。但显然,grunt仍无法找到karma模块。它吐出这个错误:

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.

我尝试过使用npm在本地和全球安装karma,但似乎什么都不管用。

5 个解决方案

#1


66  

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

#2


8  

I had to install the following

我必须安装以下软件

  npm install phantomjs
  npm install jasmine-core
  npm install karma
  npm install grunt-karma

Goodluck, Rajesh

古德勒克,拉杰什

Edit: One liner:

编辑:一个衬套:

npm install karma grunt-karma jasmine-core phantomjs

#3


4  

This work for me:

这个工作对我来说:

npm install phantomjs jasmine-core jasmine karma grunt-karma

Node version: 4.2.2

节点版本:4.2.2

#4


0  

I had the exact same problem and running npm install karma fixed it temporarily too.

我遇到了同样的问题,运行npm安装karma也临时修复了它。

The issue though wasn't that karma hadn't been initialized but rather that the repository that we were using had node_modules checked in without karma's debug folder.

但问题并不是karma没有被初始化,而是我们使用的存储库中没有karma的调试文件夹node_modules。

This was all because the .gitignore file was ignoring all the debug folders for checkins. Make sure your .gitignore file isn't ignoring things you want

这都是因为.gitignore文件忽略了所有检查的调试文件夹。确保你的。gitignore文件没有忽略你想要的东西

#5


-1  

npm install karma
npm install grunt-karma 

above command will fix the issue.

上面的命令将修复这个问题。

#1


66  

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

#2


8  

I had to install the following

我必须安装以下软件

  npm install phantomjs
  npm install jasmine-core
  npm install karma
  npm install grunt-karma

Goodluck, Rajesh

古德勒克,拉杰什

Edit: One liner:

编辑:一个衬套:

npm install karma grunt-karma jasmine-core phantomjs

#3


4  

This work for me:

这个工作对我来说:

npm install phantomjs jasmine-core jasmine karma grunt-karma

Node version: 4.2.2

节点版本:4.2.2

#4


0  

I had the exact same problem and running npm install karma fixed it temporarily too.

我遇到了同样的问题,运行npm安装karma也临时修复了它。

The issue though wasn't that karma hadn't been initialized but rather that the repository that we were using had node_modules checked in without karma's debug folder.

但问题并不是karma没有被初始化,而是我们使用的存储库中没有karma的调试文件夹node_modules。

This was all because the .gitignore file was ignoring all the debug folders for checkins. Make sure your .gitignore file isn't ignoring things you want

这都是因为.gitignore文件忽略了所有检查的调试文件夹。确保你的。gitignore文件没有忽略你想要的东西

#5


-1  

npm install karma
npm install grunt-karma 

above command will fix the issue.

上面的命令将修复这个问题。