karma-browserify: Can not load "browserify", it is not registered!

I am getting the error Can not load "browserify" when executing karma start:

06 06 2016 13:59:31.442:WARN [plugin]: Error during loading “C:\Users\Benny\AppData\Roaming\npm\node_modules/karma-requirejs” plugin: Cannot find module ‘requirejs’ 06 06 2016 13:59:31.450:WARN [preprocess]: Can not load “browserify”, it is not registered! Perhaps you are missing some plugin? C:\Users\Benny\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:9 throw error(‘No provider for "’ + name + ‘"!’); ^ Error: No provider for “framework:browserify”! (Resolving: framework:browserify)

Can you help my finding out why this happens?

Here is my package.json:

{
  "name": "node-app",
  "version": "1.0.0",
  "main": "js/calc.js",
  "private": true,
  "devDependencies": {
    "browserify": "^13.0.1",
    "jasmine-core": "^2.4.1",
    "karma": "^0.13.22",
    "karma-browserify": "^5.0.5",
    "karma-chrome-launcher": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-requirejs": "^1.0.0",
    "requirejs": "^2.2.0",
    "watchify": "^3.7.0"
  }
}

And my karma.conf.js:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['browserify', 'jasmine'],
    files: [
      'js/*.js',
      'test/*Spec.js'
    ],
    exclude: [],
    preprocessors: {
      'test/*Spec.js': ['browserify']
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: false,
    browsers: ['Chrome'],
    browserify: {
      debug: true,
      transform: []
    },
    singleRun: false,
    concurrency: Infinity
  });
};

My CalcSpec.js is this:

/* global expect */
var calc = require('../js/calc.js');

describe('Perimeter', function () {
  it('can calculate the perimeter for a rectangular', function () {
    var length = 4;
    var width = 5;

    var perimeter = calc.perimeter(length, width);
    var expected = 19;

    expect(perimeter).toBe(expected);
  });
});

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

I was having the same problem on OSX. I was able to fix it by installing karma-browserify globally with: npm install -g karma-browserify. I believe this works because when running karma start you are invoking karma from usr/local/bin, so karma tries to resolve karma-browserify from that directory, which won’t work unless its installed globally. I could be wrong though.