Karma runs on Node.js and is available via NPM.
There are installers for both Mac and Windows. On Linux, we recommend using NVM.
NPM is a package manager for Node.js which is used to install Karma. This should automatically be installed when Node.js is installed, but if not then please install it afterwards.
This is the recommended approach to installing and making use of Karma. It will install Karma into your global
node_modules
directory and create a symlink in your system path, so that you can run the karma
command from any directory. This means that the karma
command (which is the central command that Karma uses to run
tests) can be executed anywhere via the command line.
The following command will install Karma globally:
$ npm install -g karma
Please note, that the karma
command will always look for a locally installed instance of Karma first and
before resorting to a global install and, if present, then the local version will be utilized.
This allows you to use different version of Karma per project.
A local installation will install Karma into your current directory's node_modules
.
$ npm install karma --save-dev
The karma command can now be also executed directly from the node_modules directory:
$ ./node_modules/.bin/karma