title: Angular 6 and karma 'Can not load "@angular-devkit/build-angular", it is not registered'
body: <p>I had to migrate to the newest angular version. After that, karma tests stopped working and just keep crushing with an error log:</p>
  
  <blockquote>
    <p>14 04 2018 14:17:00.453:ERROR [preprocess]: Can not load "@angular-devkit/build-angular", it is not registered!
      Perhaps you are missing some plugin?</p>
    
    <p>...\parkandrest-ui\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins\packages\angular_devkit\build_angular\src\angular-cli-files\plugins\karma.ts:52
    const options = config.buildWebpack.options;
                                          ^ TypeError: Cannot read property 'options' of undefined
        at init (...\parkandrest-ui\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins\packages\angular_devkit\build_angular\src\angular-cli-files\plugins\karma.ts:52:39)
        at Array.invoke (...\parkandrest-ui\node_modules\di\lib\injector.js:75:15)
        at Injector.get (...\parkandrest-ui\node_modules\di\lib\injector.js:48:43)
        at E:\Workspace\Training\spring-boot-tutorial\parkandrest-ui\node_modules\karma\lib\server.js:166:20
        at Array.forEach ()
        at Server._start (...\parkandrest-ui\node_modules\karma\lib\server.js:165:21)
        at Injector.invoke (...\parkandrest-ui\node_modules\di\lib\injector.js:75:15)
        at Server.start (...\parkandrest-ui\node_modules\karma\lib\server.js:126:18)
        at Object.</p>
  </blockquote>
  
  <p>My karma.conf.js file looks like this:</p>
  
  <pre><code>module.exports = function (config) {
    config.set({
      basePath: '',
      frameworks: ['jasmine', '@angular-devkit/build-angular'],
      plugins: [
        require('karma-jasmine'),
        require('karma-chrome-launcher'),
        require('karma-jasmine-html-reporter'),
        require('karma-coverage-istanbul-reporter'),
        require('@angular-devkit/build-angular/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-devkit/build-angular']
      },
      mime: {
        'text/x-typescript': ['ts','tsx']
      },
      coverageIstanbulReporter: {
        dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
        fixWebpackSourcePaths: true
      },
      angularCli: {
        config: './angular.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>
  
  <p>@angular-devkit\build-angular is of course installed. I appreciate any help.  </p>
  
  <p>EDIT:
  I have a solution which actually combines most of the user answers to my question with my own. Firstly I updated my whole project to stable angular 6 release. Next, I generated empty project like @R.Richards suggested and then I replaced almost every configuration in my old project with the new one. Finally, I have encountered a problem @Suvendu warn me about. I used his solution to resolve it. Unfortunately, I still have one problem with my environment (Intellij IDEA 2017.3.4 Ultimate) which disallows me to start karma tests directly from my IDE ( I've got the same error @Suvendu mentions about), however, it is a topic for the next question. </p>