Karma: Karma cant find the npm modules

Created on 10 Jul 2015  ·  12Comments  ·  Source: karma-runner/karma

Node version: v0.12.7
NPM version: 2.13.0

For some reason karma cannot find some modules. Note: I'm also requesting karma-mocha and this doesnt throw a warning.

jon % karma start
WARN [plugin]: Cannot find plugin "karma-chai".
  Did you forget to install it ?
  npm install karma-chai --save-dev
WARN [plugin]: Cannot find plugin "karma-jspm".
  Did you forget to install it ?
  npm install karma-jspm --save-dev

/Users/jon/.npm-packages/lib/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
            ^
Error: No provider for "framework:chai"! (Resolving: framework:chai)
    at error (/Users/jon/.npm-packages/lib/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (/Users/jon/.npm-packages/lib/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (/Users/jon/.npm-packages/lib/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at /Users/jon/.npm-packages/lib/node_modules/karma/lib/server.js:29:14
    at Array.forEach (native)
    at start (/Users/jon/.npm-packages/lib/node_modules/karma/lib/server.js:28:21)
    at invoke (/Users/jon/.npm-packages/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (/Users/jon/.npm-packages/lib/node_modules/karma/lib/server.js:307:12)
    at Object.exports.run (/Users/jon/.npm-packages/lib/node_modules/karma/lib/cli.js:220:27)
    at Object.<anonymous> (/Users/jon/.npm-packages/lib/node_modules/karma/bin/karma:3:23)

But the plugin is installed

jon % npm list karma-jspm
[email protected] /Users/jon/projects/test
└── [email protected]

My package.json

{
  "name": "reportum_data_analysis_ui",
  "version": "0.0.1",
  "description": "The Reportum Clinical Dashboard",
  "scripts": {},
  "author": "",
  "license": "ISC",
  "jspm": {
    "directories": {},
    "dependencies": {
      "bootcards": "bower:bootcards@^1.1.2",
      "classnames": "npm:classnames@^2.1.2",
      "fetch": "github:github/fetch@^0.9.0",
      "ramda": "npm:ramda@^0.15.1",
      "react": "npm:react@^0.14.0-alpha3",
      "react-google-charts": "npm:react-google-charts@^0.1.4"
    },
    "devDependencies": {
      "babel": "npm:babel-core@^5.1.13",
      "babel-runtime": "npm:babel-runtime@^5.1.13",
      "core-js": "npm:core-js@^0.9.4"
    }
  },
  "devDependencies": {
    "babel-eslint": "^3.1.20",
    "babel-jest": "^5.3.0",
    "chai": "^3.0.0",
    "classnames": "^2.1.3",
    "cssnext": "^1.8.0",
    "eslint": "^0.24.0",
    "eslint-plugin-react": "^2.6.3",
    "http-server": "^0.8.0",
    "jest": "^0.1.40",
    "karma": "^0.12.37",
    "karma-babel-preprocessor": "^5.2.1",
    "karma-chai": "^0.1.0",
    "karma-jspm": "^2.0.0-beta.1",
    "karma-mocha": "^0.2.0",
    "karma-sinon": "^1.0.4",
    "mocha": "^2.2.5",
    "onchange": "^1.1.0",
    "parallelshell": "latest",
    "postcss": "^4.1.13",
    "postcss-cli": "^1.3.1",
    "postcss-nested": "^0.3.2",
    "react": "^0.13.3",
    "sinon": "^1.15.4"
  },
  "dependencies": {
  }
}

My karma conf file

// Karma configuration
// Generated on Fri Jul 10 2015 08:21:56 GMT+0100 (BST)

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

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

    plugins: ['karma-mocha', 'karma-chai', 'karma-jspm'],


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



    // list of files / patterns to load in the browser
    files: [],

    jspm: {
      loadFiles: ['source/**/*.spec.js']
    },


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


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {},


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


    // web server port
    port: 9876,


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


    // 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: true,


    // 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
  })
}
support

Most helpful comment

That's the problem then, you should use karma-cli globally, http://karma-runner.github.io/0.12/intro/installation.html
If you install karma globally it doesn't use the local installation.

All 12 comments

What binary are you using? Do you have karma or karma-cli installed globaly?

I'm using the globally installed karma.

That's the problem then, you should use karma-cli globally, http://karma-runner.github.io/0.12/intro/installation.html
If you install karma globally it doesn't use the local installation.

npm i -g karma-cli did the trick thank you @Dignifiedquire

thx a lot, I got the same problem also~

Starting karma from ./node_modules/karma/bin/karma start karma.conf.js worked just fine for me. No need to intall such CLI globally. Where node_modules is the project local node_modules folder

Getting same problem on node 4.2, with karma as global, Cannot find plugin "karma-jasmine".

but worked using local installed lib (on windows ) node node_moduleskarma\binkarma start karma.conf.js

karma should NOT be installed globally, it will not work! Install karma-cli if you want a global cmd and install karma + plugins locally

+1 thanks @Dignifiedquire .

So to be specific:

npm install -g karm-cli
npm install -D karma

is that right? seems weird that the karma executable would interfere with the karma-cli executable if you installed both globally...

@dignifiedquire OMG I LOVE YOU!!! I was screaming when Karma couldn't find the NPM modules I installed. Thank you so much.

=> const { LOG_DEBUG } = require('karma/lib/constants');
this auto import when i press LOG :)
I active Caps Lock => Err.
You can find and delete 'const { LOG_DEBUG } = require('karma/lib/constants');'

Was this page helpful?
0 / 5 - 0 ratings