Integrating Karma and webstorm

All we need is an easy explanation of the problem, so here it is.

I would like to integrate Karma and webstorm for windows, I have followed the steps from this web: (translate it to english) but does not work.

I have created one Karma Server and a Karma run:

In Path to Node Js File textfield, I have pointed to a karma file from the node-modules:


In the application parameters for the server start and for the Karma Run run

I get the following errors:

    throw err;
Error: Cannot find module 'optimist'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (C:\Users\Javito\AppData\Roaming\npm-cache\karma\0.8.4\package\lib\cli.js:2:16)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)

Process finished with exit code 1

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

The problem was the Karma execution file (Path to node App JS file) I was pointing to, here is my configuration for both server and run:

Karma Server:

Karma server config

Karma Run:

Karma Run config

Method 2

Trying to run sails app(app.js nodejs) in Webstorm gave me the optimist error in Ubuntu 14(32 bits). I fixed it by running:

sudo npm install optimist


Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply