nikku / karma-browserify

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

Can not load "browserify", it is not registered! #192

Closed bennycode closed 7 years ago

bennycode commented 8 years ago

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);
  });
});
bennycode commented 8 years ago

To solve the "Cannot find module 'requirejs'" issue I did npm install -g requirejs. But when using karma start I still have this issue (on Windows 10 Home):

06 06 2016 15:38:59.402:WARN [plugin]: Cannot find plugin "karma-browserify". Did you forget to install it ? npm install karma-browserify --save-dev 06 06 2016 15:38:59.409: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 + '"!');

And I definetly executed npm install karma-browserify --save-dev. I also added plugins to karma.conf.js:

...
    singleRun: false,
    concurrency: Infinity,
    plugins: [
      'karma-browserify'
    ]
...
nikku commented 8 years ago

What about the following?

rm -rf node_modules # remove node modules directory in your project
npm install #reinstall all dependencies
bennycode commented 8 years ago

I already tried that. By the way, I have the same issue when trying to run your example code: https://github.com/nikku/karma-browserify/tree/master/example

D:\dev\projects\temp\karma-browserify\example>karma start 06 06 2016 16:59:39.425:DEBUG [plugin]: Loading karma-* from C:\Users\Benny\AppData\Roaming\npm\node_modules 06 06 2016 16:59:39.431:DEBUG [plugin]: Loading plugin C:\Users\Benny\AppData\Roaming\npm\node_modules/karma-chrome-launcher. 06 06 2016 16:59:39.488:DEBUG [plugin]: Loading plugin C:\Users\Benny\AppData\Roaming\npm\node_modules/karma-coffee-preprocessor. 06 06 2016 16:59:39.619:DEBUG [plugin]: Loading plugin C:\Users\Benny\AppData\Roaming\npm\node_modules/karma-jasmine. 06 06 2016 16:59:39.628:DEBUG [plugin]: Loading plugin C:\Users\Benny\AppData\Roaming\npm\node_modules/karma-mocha. 06 06 2016 16:59:39.637:DEBUG [plugin]: Loading plugin C:\Users\Benny\AppData\Roaming\npm\node_modules/karma-requirejs. 06 06 2016 16:59:39.652:WARN [preprocess]: Can not load "browserify", it is not registered! Perhaps you are missing some plugin? module.js:328 throw err; ^ Error: Cannot find module 'jasmine-core'

I am using node v5.3.0 on Windows 10 Home. Is karma-browserify (and it's dependencies) compatible with Windows?

By the way... Hello from Berlin to Berlin. :grinning:

ghost commented 8 years ago

same issue here.

nikku commented 8 years ago

@Moezalez also on Windows?

I have no Windows to checkout that stuff here. Will see if I can get a Windows VM from somewhere and try to reproduce the problem.

ghost commented 8 years ago

@nikku it was on OSX

Kopleman commented 8 years ago

win10 same problem

nikku commented 8 years ago

Please post your nodejs / npm version, too.

Kopleman commented 8 years ago

Sorry, {npm: '2.15.5', node: '4.4.5'}

Jskobos commented 8 years ago

I'm having the same problem on OSX (10.11.5), with node 6.3.0 and npm 3.10.3.

16 08 2016 23:48:16.209:DEBUG [plugin]: Loading plugin karma-browserify. 16 08 2016 23:48:16.213:ERROR [plugin]: Cannot find plugin "karma-browserify". Did you forget to install it? npm install karma-browserify --save-dev 16 08 2016 23:48:16.213:DEBUG [karma]: Registered a load error of type plug_in with name karma-browserify 16 08 2016 23:48:16.216:ERROR [preprocess]: Can not load "browserify", it is not registered! Perhaps you are missing some plugin?

nghilevi commented 8 years ago

same here. I run it using Webstorm.

29 08 2016 23:31:45.862:WARN [preprocess]: Can not load "browserify", it is not registered!
  Perhaps you are missing some plugin?
/Users/.../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)
nikku commented 8 years ago

What's your NodeJS / NPM version / package.json like?

nghilevi commented 8 years ago

Sorry I fixed it already. I actually follow this guy http://stackoverflow.com/a/30781687. But what he did not mention is you have to add 'karma-browserify' in the plugin field. I also leave a comment there for others who may face the same problem.

foobarmeow commented 7 years ago

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.

nikku commented 7 years ago

Closing this, as we cannot reproduce it ourselves and a workaround exists.

Jeff-Tian commented 4 years ago

npm install -g karma-browserify

I am facing this issue on windows 10 too. Found this answer and get inspired and verified that npm install --save-dev karma-browserify can actually work, too.