Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you run Karma after installation?

I'm trying to use karma for different watch processes.

I installed karma globally with:

npm i -g karma

Then ran karma start karma.conf.js and it worked.

Now I need to install karma locally inside the project with

npm install karma

It seems to install it fine since I have the folder karma in node_modules, however, node_modules/karma/bin/karma seems not to be the executable file to run.

How should I run karma after installing it locally?

like image 740
Pablo Avatar asked Jan 22 '16 12:01

Pablo


2 Answers

To run locally on Windows (I'm on Windows 10), I recommend adding the following to your package.json file.

 "scripts": {
    "test": "cd ./node_modules/karma/bin/ && karma start"
  },

Then from the command line, type npm run test

I prefer to not install a cli globally for these kinds of tools and instead run them locally from my project using a script. This way I can quickly see what version is in the dev dependencies and don't have to worry about the global version being different from the local one.

"devDependencies": {
    "karma": "^1.4.0"
 }
like image 178
Thomas Rundle Avatar answered Oct 16 '22 20:10

Thomas Rundle


To run Karma after installing it locally:

# Run Karma:
$ ./node_modules/karma/bin/karma start

Typing ./node_modules/karma/bin/karma start sucks and so you might find it useful to install karma-cli globally. You will need to do this if you want to run Karma on Windows from the command line.

$ npm install -g karma-cli

Then, you can run Karma simply by karma from anywhere and it will always run the local version.

like image 39
Andrew Hendrie Avatar answered Oct 16 '22 20:10

Andrew Hendrie