2015-07-16 17 views
5

Tôi nhận được lỗi này;Karma không thể tải webpack

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 của tôi trông giống như;

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! 
    } 
    }); 
}; 

và 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); 

tôi có nghiệp chướng và nghiệp-webpack cài đặt.

Bất kỳ ý tưởng nào?

+0

Tại sao yêu cầu webpack của bạn trong karma.conf? 'var webpack = require ('webpack'); ' – dignifiedquire

Trả lời

5

Điều gì đó đã thay đổi trong các phiên bản mới nhất của các dự án nghiệp vụ. Tôi đã có cùng một vấn đề như tôi đã cài đặt mọi thứ mới nhất. Bây giờ tôi đã thử chính xác các phiên bản here và nó đã hoạt động.

+1

Tôi đã gửi một vấn đề [ở đây] (https://github.com/karma-runner/karma/issues/1497) –

+0

Cảm ơn điều này là nó. – Bulkan

6

Tôi đã gặp lỗi tương tự nhưng bài đăng được tham chiếu trong giải pháp được chấp nhận không hoạt động đối với tôi. Nếu bạn đang tìm kiếm các giải pháp thay thế, hãy đọc bên dưới!


Tôi đã nhìn thấy thông báo lỗi sau:

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) 

tôi tìm thấy giải pháp này trên một vấn đề Github:

https://github.com/webpack/karma-webpack/issues/65

Dưới đây là là những dòng cập nhật trong package.json của tôi:

"karma": "^0.13.3", 
"karma-chrome-launcher": "^0.2.0", 
"karma-jasmine": "^0.3.6", 
"karma-webpack": "^1.7.0", 

Hy vọng điều này sẽ hữu ích.

1

Bạn nên nâng cấp gói "nghiệp" và "karma-webpack". Có ngoại lệ tương tự, nâng cấp lên phiên bản tiếp theo đã giải quyết vấn đề này:

"karma": "0.13.18", 
"karma-webpack": "1.7.0" 
Các vấn đề liên quan