我收到此错误;

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)

我的karma.conf看起来像;
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!
    }
  });
};

和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);

我确实安装了 karma 和 karma webpack。

有任何想法吗 ?

最佳答案

最新版本的karma- *项目已发生了一些变化。我在安装所有最新产品时遇到了同样的问题。现在,我完全尝试了here版本,它成功了。

关于javascript - karma 无法加载Webpack,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31444743/

10-14 05:41