Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot load 'webpack' #70

Closed
jingzhou123 opened this issue Aug 4, 2015 · 24 comments
Closed

cannot load 'webpack' #70

jingzhou123 opened this issue Aug 4, 2015 · 24 comments

Comments

@jingzhou123
Copy link

Errors:
Can not load "webpack"!
  TypeError: undefined is not a function
    at Plugin.notifyKarmaAboutChanges (/Users/jz/jsfiddles/template/node_modules/karma-webpack/index.js:108:15)
    at Plugin.<anonymous> (/Users/jz/jsfiddles/template/node_modules/karma-webpack/index.js:72:9)
    at Tapable.applyPlugins (/Users/jz/jsfiddles/template/node_modules/webpack/node_modules/tapable/lib/Tapable.js:26:37)
    at Watching._done (/Users/jz/jsfiddles/template/node_modules/webpack/lib/Compiler.js:78:17)
    at Watching.<anonymous> (/Users/jz/jsfiddles/template/node_modules/webpack/lib/Compiler.js:61:18)
    at Tapable.emitRecords (/Users/jz/jsfiddles/template/node_modules/webpack/lib/Compiler.js:281:37)
    at Watching.<anonymous> (/Users/jz/jsfiddles/template/node_modules/webpack/lib/Compiler.js:58:19)
    at /Users/jz/jsfiddles/template/node_modules/webpack/lib/Compiler.js:274:11
    at Tapable.applyPluginsAsync (/Users/jz/jsfiddles/template/node_modules/webpack/node_modules/tapable/lib/Tapable.js:60:69)
    at Tapable.afterEmit (/Users/jz/jsfiddles/template/node_modules/webpack/lib/Compiler.js:271:8)

here is my package.json file

{
  "name": "components",
  "version": "0.0.1",
  "description": "components",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {




  },
  "devDependencies": {
    "babel-core": "^5.8.9",
    "babel-loader": "^5.3.2",
    "css-loader": "^0.15.6",
    "jasmine-core": "^2.3.4",
    "karma": "^0.12.37",
    "karma-chrome-launcher": "^0.2.0",
    "karma-jasmine": "^0.3.6",
    "karma-sourcemap-loader": "^0.3.5",
    "karma-webpack": "^1.6.0",
    "less": "^2.5.1",
    "less-loader": "^2.2.0",
    "lodash": "^3.10.0",
    "style-loader": "^0.12.3",
    "webpack": "^1.10.5"
  }
}

I change karma version to ~0.12.37 and karma-webpack to ~1.6.0,it works;
But when karma-webpack is 1.7.0, it throw errors when I run karma start karma.config.js

@dignifiedquire
Copy link
Collaborator

Duplicate of #68 and see #63 for more details. You need to upgrade karma to 0.13 to fix the issue

@pojka
Copy link

pojka commented Aug 4, 2015

I'm seeing this issue with fixed versions of karma 0.13.4 and karma-webpack 1.7.0

Can not load "webpack"!
  TypeError: undefined is not a function
    at Plugin.notifyKarmaAboutChanges (/Projects/utilass/node_modules/karma-webpack/index.js:108:15)

@dignifiedquire
Copy link
Collaborator

@pojka could you show me the output of npm ls please

@pojka
Copy link

pojka commented Aug 4, 2015

@dignifiedquire sure - https://gist.github.com/pojka/49307fbb77d1c0ee18ed

Please let me know if I'm being dumb :)

@dignifiedquire
Copy link
Collaborator

@pojka looks like there is another bug in there :( thanks for the report

@kmaraz
Copy link

kmaraz commented Aug 11, 2015

I have the same problem, how can I temporarily solve this? Or I need to wait for fix? Thanks.

EDIT: Or can I help you with my logs?

@pojka
Copy link

pojka commented Aug 11, 2015

@kmaraz using the following combination works for me for the moment:

"karma": "0.12.37", "karma-webpack": "1.6.0",

@kmaraz
Copy link

kmaraz commented Aug 11, 2015

@pojka Thanks!
@dignifiedquire If you need my logs, just tell me, please.

@andrevinsky
Copy link

Hello, isn't there a way NOT to use old versions? 👍

@leoselig
Copy link

+1
we are experiencing the same issue

@dignifiedquire
Copy link
Collaborator

Does someone have repo which fails with this error, using [email protected] and [email protected] that I could look at?

mr-mig added a commit to mr-mig/frontend-library-starter that referenced this issue Aug 16, 2015
mr-mig added a commit to mr-mig/frontend-library-starter that referenced this issue Aug 16, 2015
mr-mig added a commit to mr-mig/originate-frontend-lib that referenced this issue Aug 16, 2015
@ebordeau
Copy link

I updated to [email protected] and [email protected] and it worked for me. Thanks!

@pojka
Copy link

pojka commented Aug 19, 2015

@dignifiedquire not working for me with [email protected] and [email protected] either

I've stripped everything down to a very basic config and a hello world test, repo is here - https://github.com/pojka/debug-karma-webpack-70

If you change to [email protected] and [email protected] the test runs

@thomasklein
Copy link

Hi! [email protected] and [email protected] also did not work for me, so I downgraded to [email protected] and [email protected] and it triggers the following error (which I think is new in the current stack of error messages and might therefore have another cause):

WARN [preprocess]: Can not load "webpack"!
  Error: Invalid arguments: 'delay'
    at NodeWatchFileSystem.watch (/xxx/node_modules/webpack/lib/node/NodeWatchFileSystem.js:29:9)
    at Watching.watch (/xxx/node_modules/webpack/lib/Compiler.js:86:47)
    at Watching._done (/xxx/node_modules/webpack/lib/Compiler.js:82:8)
    at Watching.<anonymous> (/xxx/node_modules/webpack/lib/Compiler.js:60:18)
    at Tapable.emitRecords (/xxx/node_modules/webpack/lib/Compiler.js:279:37)
    at Watching.<anonymous> (/xxx/node_modules/webpack/lib/Compiler.js:57:19)
    at /xxx/node_modules/webpack/lib/Compiler.js:272:11
    at Tapable.applyPluginsAsync (/xxx/node_modules/webpack/node_modules/tapable/lib/Tapable.js:60:69)
    at Tapable.afterEmit (/xxx/node_modules/webpack/lib/Compiler.js:269:8)
    at Tapable.<anonymous> (/xxx/node_modules/webpack/lib/Compiler.js:264:14)

with the karma.config

module.exports = function(config) {
    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: pathToSrcJS,

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['jasmine'],

        // list of files / patterns to load in the browser
        files: [
            // project specific SETUP necessary for tests
            'components_tests/setup.js',

            // include all test files
            'components_tests/test_index.js'
        ],
        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {
            'components_tests/test_index.js': ['webpack', 'coverage'],
            'components_tests/setup.js': ['webpack']
        },

        // list of files to exclude
        exclude: [],

        // TODO refactor path and make them project agnostic
        webpack: webpackConfig,

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'coverage'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // Output summary only to console
        // Webstorm/Intellij have an integrated coverage view
        coverageReporter: {
            reporters: [{
                type: 'text'
            }]
        },

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['PhantomJS'],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: true,

        plugins: [
            require('karma-phantomjs-launcher'),
            require('karma-webpack'),
            require('karma-jasmine'),
            require('karma-coverage')
        ]
    });
};

@thomasklein
Copy link

My problem was solved by upgrading to the latest version of webpack.

@claudiopro
Copy link

Same issue here. I'm running a clone of https://github.com/pheuter/essential-react with

Full output of npm ls here

@dignifiedquire
Copy link
Collaborator

@claudiopro you need to upgrade karma to 0.13

@claudiopro
Copy link

@dignifiedquire thanks, [email protected] did solve the issue!

@dignifiedquire
Copy link
Collaborator

@pojka @jingzhou123 I've just checked you repo and everything is working fine for me, I ran

$ npm install
$ node_modules/.bin/karma start karma.conf.js

Could you check that you are using karma-cli and not karma installed globally, and make sure the global version which you call with karma is actually up to date.

@pojka
Copy link

pojka commented Oct 20, 2015

@dignifiedquire that was indeed the issue, thank you for your patience!

@dignifiedquire
Copy link
Collaborator

Closing this as all issues seem to have been resolved.

@joeheyming
Copy link

wow, this whole time I wasn't using node_modules/.bin/karma and was instead using the global karma.

Just wanted to say this in case anyone else had the same issue.

@besh
Copy link

besh commented Jul 19, 2016

@joeheyming Good call out. Didn't even think of that. Completely fixed my issues.

@yinsang
Copy link

yinsang commented Sep 18, 2018

Two ways to use karma start.

  1. if you had done npm install -g karma-cli, you can use karma start directly in commander(not in package.json)

  2. if you use npm scripts like
    "scripts": {
    "test": "karma start"
    },

, try npm install -SD karma-webpack webpack,then usenpm run test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests