Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma cant find the npm modules #1488

Closed
roine opened this issue Jul 10, 2015 · 12 comments
Closed

Karma cant find the npm modules #1488

roine opened this issue Jul 10, 2015 · 12 comments
Labels

Comments

@roine
Copy link

roine commented Jul 10, 2015

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
  })
}
@dignifiedquire
Copy link
Member

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

@roine
Copy link
Author

roine commented Jul 10, 2015

I'm using the globally installed karma.

@dignifiedquire
Copy link
Member

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.

@roine
Copy link
Author

roine commented Jul 10, 2015

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

@VaJoy
Copy link

VaJoy commented Oct 30, 2015

thx a lot, I got the same problem also~

@enapupe
Copy link

enapupe commented Nov 9, 2015

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

@houssemFat
Copy link

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_modules\karma\bin\karma start karma.conf.js

@dignifiedquire
Copy link
Member

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

@houssemFat
Copy link

+1 thanks @dignifiedquire .

@ORESoftware
Copy link

ORESoftware commented Aug 12, 2017

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...

@ghost
Copy link

ghost commented Feb 27, 2019

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

@thuctd
Copy link

thuctd commented Nov 16, 2020

=> 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');'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants