Reputation: 10650
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?
Upvotes: 8
Views: 4891
Reputation: 96
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"
}
Upvotes: 7
Reputation: 6415
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.
Upvotes: 1