Victor Shelepen
Victor Shelepen

Reputation: 2266

Cannot find plugin "karma-webpack"

I am struggling with testing of libraries in browsers by schema Karma, Webpack, Babel. Running the Karma

 npx karma start karma.conf.js --single-run --browsers PhantomJS

I receive the following.

13 12 2020 11:58:16.370:ERROR [plugin]: Cannot find plugin "karma-webpack".
  Did you forget to install it?
  npm install karma-webpack --save-dev

These packages are installed locally. I also have installed them globally. Still the same. There is my karma.conf.js

const webpackConfig = require('./testing.webpack.js');
module.exports = function (config) {
    config.set({
        basePath: './',
        coverageReporter: {
            dir: 'tmp/coverage/',
            reporters: [
                { type: 'html', subdir: 'report-html' },
                { type: 'lcov', subdir: 'report-lcov' }
            ],
            instrumenterOptions: {
                istanbul: { noCompact: true }
            }
        },
        files: [
            'spec/**/*.spec.js'
        ],
        frameworks: ['should', 'jasmine', 'mocha'],
        reporters: ['mocha', 'coverage'],
        preprocessors: {
            'spec/**/*.spec.js': ['webpack', 'sourcemap']
        },
        plugins: [
            'karma-webpack',
            'karma-jasmine',
            'karma-mocha',
            'karma-should',
            'karma-coverage',
            'karma-chrome-launcher',
            'karma-phantomjs-launcher',
            'karma-mocha-reporter',
            'karma-sourcemap-loader'
        ],
        webpack: webpackConfig,
        webpackMiddleware: {
           stats: 'errors-only'
        }
    });

    return config;
};

The error is confusing. Because it is easy to resolve according to the error output but it has not to be resolved. I will be pleased with a tip.

Upvotes: 0

Views: 979

Answers (1)

Victor Shelepen
Victor Shelepen

Reputation: 2266

In my case, it was an issue of incompatible packages. A similar issue is reported here. A comment helped me. Karma 5.2.3 is used. Karma-webpack: was latest:4.0.2, works with dev: 5.0.0-alpha.3.0, next: 5.0.0-alpha.5 is available.

Upvotes: 2

Related Questions