Karma can't load webpack
Solution 1
Something has changed in the latest versions of karma-* projects. I have got the same issue as I installed everything latest. Now I tried exactly the versions here and it worked out.
Solution 2
I had a similar error but the post referenced in the accepted solution did not work for me. If you're looking for alternatives, read below!
I was seeing the following error message:
WARN [preprocess]: Can not load "webpack"!
TypeError: Object [object Object] has no method 'refreshFiles'
at Plugin.notifyKarmaAboutChanges (/Users/abhandaru/workspace/source/macaw-campaigns/node_modules/karma-webpack/index.js:108:15)
at Plugin.<anonymous> (/Users/abhandaru/workspace/source/macaw-campaigns/node_modules/karma-webpack/index.js:72:9)
at Tapable.applyPlugins (/Users/abhandaru/workspace/source/macaw-campaigns/node_modules/webpack/node_modules/tapable/lib/Tapable.js:26:37)
I found this solution on a Github issue:
https://github.com/webpack/karma-webpack/issues/65
Here is are the updated lines in my package.json
:
"karma": "^0.13.3",
"karma-chrome-launcher": "^0.2.0",
"karma-jasmine": "^0.3.6",
"karma-webpack": "^1.7.0",
Hope this helps.
Solution 3
You should upgrade "karma" and "karma-webpack" packages. Had similar exception, upgrading to next versions solved this:
"karma": "0.13.18",
"karma-webpack": "1.7.0"
Related videos on Youtube
Bulkan
Software Engineer that plays the Ney https://github.com/bulkan http://queshuns.com
Updated on July 13, 2022Comments
-
Bulkan almost 2 years
I'm getting this error;
16 07 2015 13:03:52.741:WARN [preprocess]: Can not load "webpack"! Error: Can not resolve circular dependency! (Resolving: preprocessor:webpack -> webpackPlugin -> preprocessor:webpack)
My karma.conf looks like;
var webpack = require('webpack'); module.exports = function (config) { config.set({ browsers: [ 'Chrome' ], //run in Chrome singleRun: true, //just run once by default frameworks: [ 'mocha' ], //use the mocha test framework files: [ 'tests.webpack.js' //just load this file ], preprocessors: { 'tests.webpack.js': [ 'webpack', 'sourcemap' ] //preprocess with webpack and our sourcemap loader }, reporters: [ 'dots' ], //report results in this format webpack: { //kind of a copy of your webpack config devtool: 'inline-source-map', //just do inline source maps instead of the default module: { loaders: [ { test: /\.js$/, loader: 'babel-loader' } ] } }, webpackServer: { noInfo: true //please don't spam the console when running in karma! } }); };
and tests.webpack.js
var context = require.context('./src', true, /-test\.js$/); //make sure you have your directory and regex test set correctly! context.keys().forEach(context);
I do have karma and karma-webpack installed.
Any ideas ?