Karma: Cannot start karma - no provider for jasmine

Created on 19 Aug 2013  路  9Comments  路  Source: karma-runner/karma

Hey Guys:

I'm having an issue with getting karma running (on a non angularJS project) - I've installed all dependencies with npm and ran the karma init my.conf.js 2 times. When I try and run karma start my.conf.js, here's the output:

/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9
  throw error('No provider for "' + name + '"!');
        ^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
    at error (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get     (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9:13)
at get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:54:19)
at /usr/local/lib/node_modules/karma/lib/server.js:27:14
at Array.forEach (native)
at start (/usr/local/lib/node_modules/karma/lib/server.js:26:21)
at invoke (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at Object.exports.start (/usr/local/lib/node_modules/karma/lib/server.js:178:12)
at Object.<anonymous> (/usr/local/lib/node_modules/karma/bin/karma:19:39)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:275:11)

I have karma-jasmine and karma-phantomjs-launcher in node_modules, is there something else that I'm doing wrong? What else can I check?

Thanks,

  • Vann

Most helpful comment

I faced same error and tried to resolve for couple of hours.

Finally I figured out the issue. Which is "Karma module need to install LOCALLY not Globally" But you can have Karma-cli module can be installed globally.

npm uninstall karma -g
npm install karma 

# Optional
npm uninstall karma-cli
npm install karma-cli -g

All 9 comments

figured it out - I had an old version of node installed, I upgraded and everything seems to work just fine.

I'm getting this error with Node v0.12.0 and v0.10.36

These are the devDependencies that I used with Node v0.12.0:

    "jasmine": "^2.2.1",
    "karma": "^0.12.31",
    "karma-cli": "0.0.4",
    "karma-jasmine": "^0.3.5"

This is the terminal output:

Warning: Command failed: /bin/sh -c karma start karma.config.js --log-level debug
<rootDir>/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
            ^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
  at error (<rootDir>/node_modules/karma/node_modules/di/lib/injector.js:22:68)
  at Object.parent.get (<rootDir>/node_modules/karma/node_modules/di/lib/injector.js:9:13)
  at [object Object].get (<rootDir>/node_modules/karma/node_modules/di/lib/injector.js:54:19)
  at <rootDir>/node_modules/karma/lib/server.js:31:14
  at Array.forEach (native)
  at start (<rootDir>/node_modules/karma/lib/server.js:30:21)
  at [object Object].invoke (<rootDir>/node_modules/karma/node_modules/di/lib/injector.js:75:15)
  at Object.exports.start (<rootDir>/node_modules/karma/lib/server.js:314:12)
  at Object.exports.run (<rootDir>/node_modules/karma/lib/cli.js:229:25)
  at requireCliAndRun (/usr/local/lib/node_modules/karma-cli/bin/karma:24:16)
  at /usr/local/lib/node_modules/karma-cli/bin/karma:56:12
  at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:44:21
  at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:119:35
  at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:91:39
  at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:60:30
  at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:20:18
  at FSReqWrap.oncomplete (fs.js:99:15)

Does anyone know how I can fix this?

@aleclarson can you post your karma.config.js

@maksimr

// karma.config.js

module.exports = function(config) {
    config.set({
        basePath: "",
        frameworks: ["jasmine"],
        plugins: [require("karma-webpack")],
        files: ["build/**/*.js"],
        exclude: ["node_modules"],
        preprocessors: {
            "build/**/*.js": ["webpack"]
        },
        reporters: ["progress"],
        port: 9876,
        colors: true,
        logLevel: config.LOG_DEBUG,
        autoWatch: true,
        browsers: ["Chrome"],
        singleRun: false
    });
};

@aleclarson remove property plugins(then karma will by default load all plugins from node_modules by pattern karma-*) or add to it karma-jasmine.

plugins: [require("karma-webpack"), require('karma-jasmine')],

@maksimr Oh I get it. Thanks!

I faced same error and tried to resolve for couple of hours.

Finally I figured out the issue. Which is "Karma module need to install LOCALLY not Globally" But you can have Karma-cli module can be installed globally.

npm uninstall karma -g
npm install karma 

# Optional
npm uninstall karma-cli
npm install karma-cli -g

@arunkumarg Thanks for your sharing! It really helpful!

@arunkumarg Your methods are really helpful!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IgorMinar picture IgorMinar  路  5Comments

macjohnny picture macjohnny  路  5Comments

charpour picture charpour  路  3Comments

anius picture anius  路  3Comments

mboughaba picture mboughaba  路  3Comments