38

When I run karma start I get the following issues

C:\devl\JS\myProject>karma start
06 09 2015 11:30:19.133:WARN [plugin]: Cannot find plugin "karma-chrome-launcher
".
  Did you forget to install it ?
  npm install karma-chrome-launcher --save-dev
06 09 2015 11:30:19.149:WARN [plugin]: Cannot find plugin "karma-firefox-launche
r".
  Did you forget to install it ?
  npm install karma-firefox-launcher --save-dev
06 09 2015 11:30:19.159:WARN [plugin]: Cannot find plugin "karma-ie-launcher".
  Did you forget to install it ?
  npm install karma-ie-launcher --save-dev

when I do npm list I can see the dependencies at the bottom of the tree

├─┬ karma-chrome-launcher@0.2.0
│ ├─┬ fs-access@1.0.0
│ │ └── null-check@1.0.0
│ └─┬ which@1.1.1
│   └─┬ is-absolute@0.1.7
│     └── is-relative@0.1.3
├── karma-firefox-launcher@0.1.6
├─┬ karma-ie-launcher@0.2.0
│ └── lodash@3.10.1
└── karma-jasmine@0.3.6

I have tried nuking my node_dependencies and running npm install again and i'm not sure what else to try

EDIT: I have verified in my node_dependencies directory and the plugin directories are in there.

valdeci
  • 13,962
  • 6
  • 55
  • 80
Matt Westlake
  • 3,499
  • 7
  • 39
  • 80

5 Answers5

68

There are a two seemingly-similar complaints when first getting started with Karma:

[preprocess]: Can not load "webpack", it is not registered!
  Perhaps you are missing some plugin?

and

[plugin]: Cannot find plugin "karma-webpack".
  Did you forget to install it ?
  npm install karma-webpack --save-dev

The following is my best recommendation for fixing these two problems with your configuration…

"Can not load "XYZ", it is not registered!" (sic)

The typical solution to the 'Perhaps you are missing some plugin?' message is to make sure it's included within the plugins array in karma.conf.js.

plugins: [
  'karma-chrome-launcher',
  'karma-tap',
  'karma-sourcemap-loader',
  'karma-webpack' // *** This 'registers' the Karma webpack plugin.
],

"Cannot find plugin 'karma-xyz'."

If you've already installed it by running npm install karma-xyz --save-dev, but Karma still prompts (read: taunts) you with the "Did you forget to install it ?" warning, you may have a global installation of the Karma module.

Chances are that when you installed a global copy of the karma-cli using -g, you included karma (or were told to do so by a well-meaning tutorial), but that can cause problems resolving modules in certain versions (i.e., every version I've ever used). Karma's installation documentation recommends that the module should be a local installation using npm install karma --save-dev.

If you have a global Karma installation, try something like:

$ npm uninstall -g karma
$ npm install karma --save-dev
Joe Liversedge
  • 4,124
  • 26
  • 19
  • This is the complete answer. It should be accepted. – Michael Oryl May 18 '17 at 15:49
  • Worked for me. Additional note: the package "karma-cli" should be installed globally. Otherwise, the karma start command does not work on windows. Also see https://stackoverflow.com/questions/20800933/running-karma-after-installation-results-in-karma-is-not-recognized-as-an-inte – Stefan Aug 02 '19 at 08:59
22

I think that you installed these plugins globally.

I had the same problem and I solved by installing the chrome-karma-launcher using the link flag:

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

Do this with all browsers' plugins

 npm install karma-firefox-launcher --save-dev --link
 npm install karma-ie-launcher --save-dev --link

I don't know if this is the best approach, but this solved for me.

valdeci
  • 13,962
  • 6
  • 55
  • 80
6

My answer might be a very rookie one, but did you add those plugins in the plugins array in the karma config file?

For example:

    plugins: [
        'karma-jasmine-html-reporter',
        'karma-spec-reporter',
        'karma-chrome-launcher',
        'karma-jasmine',
        'karma-coverage',
        'karma-phantomjs-launcher'
    ],

Mine got resolved after I added the plugins to this array.

akhurad
  • 194
  • 6
5

I had the same problem, but i fixed by this command :

npm install -g karma-cli
Massi Issar
  • 403
  • 5
  • 23
2

Just to add if someone come acrosss!!

I was getting an annoying issue, "Cannot load browser "Chrome": it is not registered! Perhaps you are missing some plugin?" when I run 'grunt test'

I had added the plugin in plugins[] in karma.conf.js, but still I was getting this error . The issue was I didn't add the plugin into karma:options:plugins array in GruntFile.js.After I added the plugin there, the issue vanished!!

hashcoder
  • 498
  • 7
  • 19