Angular-cli: 6.0.0-beta.6 does not install plugins - npm run test fail with "Cannot find module '@angular/cli/plugins/karma'"

Created on 18 Mar 2018  路  10Comments  路  Source: angular/angular-cli

Versions

<!--
Output from: `ng --version`.
If nothing, output from: `node --version` and `npm --version`.
  Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
-->
Angular CLI: 6.0.0-beta.6
Node: 9.8.0
OS: win32 x64
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 6.0.0-beta.6
@angular-devkit/architect: 0.0.7
@angular-devkit/build-optimizer: 0.4.6
@angular-devkit/build-webpack: 0.0.7
@angular-devkit/core: 0.4.6
@angular-devkit/schematics: 0.4.6
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 6.0.0-beta.6
@schematics/angular: 0.4.6
@schematics/package-update: 0.4.6
typescript: 2.5.3
webpack: 4.1.1

Repro steps

  • Use Angular-CLI version 6.0.0-beta.6 to create new app and run npm run test

Observed behavior

<!-- Normally this includes a stack trace and some more information. -->
18 03 2018 22:04:52.691:ERROR [config]: Error in config file!
 { Error: Cannot find module '@angular/cli/plugins/karma'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:470:25)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
    at module.exports (c:\ngcli6test\abc\karma.conf.js:13:7)
    at Object.parseConfig (c:\ngcli6test\abc\node_modules\karma\lib\config.js:416:5)
    at new Server (c:\ngcli6test\abc\node_modules\karma\lib\server.js:79:20)
    at Observable_1.Observable.obs [as _subscribe] (c:\ngcli6test\abc\node_modules\@angular-devkit\build-webpack\src\karma\packages\angular_devkit\build_webpack\src\karma\index.ts:105:27)
    at Observable._trySubscribe (c:\ngcli6test\abc\node_modules\src\Observable.ts:217:19)
    at Observable.subscribe (c:\ngcli6test\abc\node_modules\src\Observable.ts:202:87)
    at Object.subscribeToResult (c:\ngcli6test\abc\node_modules\src\util\subscribeToResult.ts:34:21)
    at MergeMapSubscriber._innerSub (c:\ngcli6test\abc\node_modules\src\operators\mergeMap.ts:138:14)
    at MergeMapSubscriber._tryNext (c:\ngcli6test\abc\node_modules\src\operators\mergeMap.ts:134:10)
    at MergeMapSubscriber._next (c:\ngcli6test\abc\node_modules\src\operators\mergeMap.ts:118:12)
    at MergeMapSubscriber.Subscriber.next (c:\ngcli6test\abc\node_modules\src\Subscriber.ts:96:12)
    at MapSubscriber._next (c:\ngcli6test\abc\node_modules\src\operators\map.ts:83:22) code: 'MODULE_NOT_FOUND' }

Desired behavior

Mention any other details that might be useful (optional)

Using Angular-CLI 1.7.0 to create application generates plugins folder under @angular\cli - it is missing in Angular-CLI 6.0.0-beta.6

devkibuild-angular

Most helpful comment

Just to close the loop here, following @cexbrayat's suggestion, my working karma.conf.js now looks like:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-webpack'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-webpack/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    customLaunchers: {
      ChromeNoSandbox: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },
    singleRun: false
  });
};

I'm using:

  • angular 6.0.0-rc.0 (all angular dependencies)
  • @angular/cli": "6.0.0-beta.6"
  • added "@angular-devkit/build-webpack": "0.0.7"

All 10 comments

Same here!

Same here too!

Any temporary solution for this?

You need to replace @angular/cli by @angular-devkit/build-webpack in karma.conf.js.

But there are a lot of breaking changes in this beta release: if you want to use the CLI without trouble, you should stay on 1.7.x for now.

beta.3 is good enough!

Yup, but beta.6 introduced architect, and a lot of things changed (command flags have been removed or renamed, config files have changed...).

Just to close the loop here, following @cexbrayat's suggestion, my working karma.conf.js now looks like:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-webpack'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-webpack/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    customLaunchers: {
      ChromeNoSandbox: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },
    singleRun: false
  });
};

I'm using:

  • angular 6.0.0-rc.0 (all angular dependencies)
  • @angular/cli": "6.0.0-beta.6"
  • added "@angular-devkit/build-webpack": "0.0.7"

@filipesilva can we close the issue or it's still valid after architect?

Please try the latest stable release. If you still hit the same problem file a new issue.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings