2015-07-16 18 views
5

Ricevo questo errore;Karma non può caricare il pacchetto web

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) 

Il mio karma.conf assomiglia;

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

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

Io ho il karma e il karma-webpack installati.

Qualche idea?

+0

Perché è necessario il Webpack nel proprio karma.conf? 'var webpack = require ('webpack');' – dignifiedquire

risposta

5

Qualcosa è cambiato nelle ultime versioni dei progetti karma- *. Ho lo stesso problema con cui ho installato tutto il più recente. Ora ho provato esattamente le versioni here e ha funzionato.

+1

Ho archiviato un problema [qui] (https://github.com/karma-runner/karma/issues/1497) –

+0

Grazie. – Bulkan

6

Ho avuto un errore simile ma il post di riferimento nella soluzione accettata non ha funzionato per me. Se stai cercando alternative, leggi qui sotto!


che stavo vedendo il seguente messaggio di errore:

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) 

ho trovato questa soluzione su un tema Github:

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

Ecco sono le linee aggiornati nel mio package.json:

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

Spero che questo aiuti.

1

È necessario aggiornare i pacchetti "karma" e "karma-webpack". Ha avuto un'eccezione simile, l'aggiornamento alle prossime versioni risolto questo:

"karma": "0.13.18", 
"karma-webpack": "1.7.0" 
Problemi correlati