title: Cannot run Karma with Angular-cli
body: <p>I encounter a strange problem that happens to one of my projects and cannot reproduce it in others even with exactly the same setup.</p>
  
  <p>Every time I try to run <code>ng test</code> or the alias <code>npm test</code> I'm getting errors that two modules are missing (<code>karma-jasmine-html-reporter</code> &amp; <code>karma-coverage-istanbul-reporter</code>). The modules though are for sure there! For example:</p>
  
  <blockquote>
    <p>web-app@0.0.3-alpha test /Users/vassilis/Projects/WebApp
    ng test</p>
    
    <p>07 03 2017 12:08:27.157:ERROR [config]: Error in config file!
     { Error: Cannot find module 'karma-jasmine-html-reporter'
        at Function.Module._resolveFilename (module.js:469:15)
        at Function.Module._load (module.js:417:25)
        at Module.require (module.js:497:17)
        at require (internal/module.js:20:19)
        at module.exports (/Users/vassilis/Projects/WebApp/karma.conf.js:11:7)
        at Object.parseConfig (/Users/vassilis/Projects/WebApp/node_modules/karma/lib/config.js:342:5)
        at new Server (/Users/vassilis/Projects/WebApp/node_modules/karma/lib/server.js:56:20)
        at /Users/vassilis/Projects/WebApp/node_modules/@angular/cli/tasks/test.js:26:31
        at Class.run (/Users/vassilis/Projects/WebApp/node_modules/@angular/cli/tasks/test.js:10:16)
        at Class.run (/Users/vassilis/Projects/WebApp/node_modules/@angular/cli/commands/test.js:29:25)
        at Class. (/Users/vassilis/Projects/WebApp/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
        at process._tickCallback (internal/process/next_tick.js:103:7) code: 'MODULE_NOT_FOUND' }
    npm ERR! Test failed.  See above for more details.</p>
  </blockquote>
  
  <p>This is my setup:</p>
  
  karma.conf.js
  
  <pre><code>module.exports = function (config) {
    config.set({
      basePath: '',
      frameworks: ['jasmine', '@angular/cli'],
      plugins: [
        require('karma-jasmine'),
        require('karma-chrome-launcher'),
        require('karma-jasmine-html-reporter'),
        require('karma-coverage-istanbul-reporter'),
        require('@angular/cli/plugins/karma')
      ],
      client:{
        clearContext: false // leave Jasmine Spec Runner output visible in browser
      },
      files: [
        { pattern: './src/test.ts', watched: false }
      ],
      preprocessors: {
        './src/test.ts': ['@angular/cli']
      },
      mime: {
        'text/x-typescript': ['ts','tsx']
      },
      coverageIstanbulReporter: {
        reports: [ 'html', 'lcovonly' ],
        fixWebpackSourcePaths: true
      },
      angularCli: {
        config: './angular-cli.json',
        environment: 'dev'
      },
      reporters: config.angularCli &amp;&amp; config.angularCli.codeCoverage
                ? ['progress', 'coverage-istanbul']
                : ['progress', 'kjhtml'],
      port: 9876,
      colors: true,
      logLevel: config.LOG_INFO,
      autoWatch: true,
      browsers: ['Chrome'],
      singleRun: false
    });
  };
  </code></pre>
  
  And the related part in <code>angular-cli.json</code>:
  
  <pre><code>"test": {
      "karma": {
        "config": "./karma.conf.js"
      }
    }
  </code></pre>
  
  <p>I am really confused over here. It seems project related issue but I cannot be sure if Karma don't even run at all. Any ideas on this?</p>