nikku / karma-browserify

A fast Browserify integration for Karma that handles large projects with ease
MIT License
321 stars 49 forks source link

'require is not defined' #139

Closed alexreardon closed 9 years ago

alexreardon commented 9 years ago

I am getting the error Uncaught ReferenceError: require is not defined when attempting to use karma-browserify on line 1; even though there is no require statement on line 1. Has anyone seen this before?

// Karma configuration

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

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',
        frameworks: ['expect', 'mocha', 'sinon', 'browserify'],
        files: [
            'components/**/*.test.js'
        ],
        exclude: [],
        preprocessors: {
            'components/**/*.test.js': ['browserify']
        },
        reporters: ['progress'],
        port: 9876,
        colors: true,
        logLevel: karma.LOG_INFO,
        autoWatch: false,
        browsers: ['Chrome'],
        singleRun: true
    });
};
alexreardon commented 9 years ago

This is occurring even when there is no require in the included file

azer commented 9 years ago

I'm also getting same error with example configuration.

nikku commented 9 years ago

The latest browserify/watchify release introduced breaking changes with a number of incompatibilities. Try to use watchify <= 3.1.x && browserify <= 10.2.1 in your project and see if it fixes the issue.

Karma >= 0.13.x may have introduced some breaking changes, too. See #138.

alexreardon commented 9 years ago

Can you recommend a safe version of karma-browserify to peg to?

nikku commented 9 years ago

Working on it. Need to patch karma-browserify with a save version. For the moment, include a fixed version of watchify and browserify (see above) with your project. Together with npm depencency resolving this should add the respective libraries to the search path.

alexreardon commented 9 years ago

Thanks @nikku

nikku commented 9 years ago

See if the latest version v4.2.2 fixes the issue for you.

alexreardon commented 9 years ago

I installed the following:

"karma-browserify": "nikku/karma-browserify#7c67ac26c3b08476017fd82275b30ace3ff3957a",

(I would have installed 4.2.2 but it looks like it is not published on npm yet)

However, it looks as though I am getting the same issue.

alexreardon commented 9 years ago

Sadly I can confirm this is still occurring in 4.3.0. I am currently investigating

nikku commented 9 years ago

Could you put up an example project somewhere that reproduces the issue? I cannot reproduce the issue in my project setups.

ebednarz commented 9 years ago

@nikku FWIW, I had the same issue yesterday and downgrading to the latest karma 12.* fixed it for me. I'll see if I can put together a minimal test case today or tomorrow.

nikku commented 9 years ago

Closing this for now due to inactivity. I am going to reopen this issue, if anyone can provide me with a test case that reproduces the behavior.