question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Karma cant find the npm modules

See original GitHub issue

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
reportum_data_analysis_ui@0.0.1 /Users/jon/projects/test
└── karma-jspm@2.0.0-beta.1

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

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

23reactions
dignifiedquirecommented, Jul 10, 2015

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.

17reactions
dignifiedquirecommented, Dec 7, 2015

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'karma' while using grunt - Stack Overflow
Aborted due to warnings. I've tried installing karma both locally and globally using npm , but nothing seems to work.
Read more >
Karma - npm
If you can't find an adapter for your favourite framework, don't worry and write your own. It's not that hard and we are...
Read more >
Installation - Karma test runner
This will install karma , karma-jasmine , karma-chrome-launcher and jasmine-core packages into node_modules in your current working directory and also save ...
Read more >
Cannot find module error when running Karma tests in EAP 7
When I run or debug karma tests (which work fine from command line), I get an error about a missing intellijCli.js module.
Read more >
npm command not found | Career Karma
In the “System Variables” box, search for Path and edit it to include the path C:\Program Files\nodejs. If you don't see it there...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found