Error in config file : Cannot find module 'angular-cli/plugins/karma'

See original GitHub issue

Please provide us with the following information:

OS?

Windows 10 x64

Versions.

Please run ng --version. If there’s nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.18 node: 6.4.0

Repro steps.

Was this an app that wasn’t created using the CLI? What change did you do on your code? etc.

Created the app usin the CLI (updated yesterday to the latest version). The app works and loads in Chrome. For now there’s just an input field. I created a service using “ng g myservice” Then I wrote some tests in myservice.service.ts I ran “ng test”

The log given by the failure.

Normally this include a stack trace and some more information.

$ ng test --watch=false 22 10 2016 11:05:54.156:ERROR [config]: Error in config file! { Error: Cannot find module ‘angular-cli/plugins/karma’ at Function.Module._resolveFilename (module.js:455:15) at Function.Module._load (module.js:403:25) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at module.exports (D:\dev\wiki_a2\karma.conf.js:12:7) at Object.parseConfig (D:\dev\wiki_a2\node_modules\karma\lib\config.js:377:5) at new Server (D:\dev\wiki_a2\node_modules\karma\lib\server.js:56:20) at C:\Users\Elg\AppData\Roaming\npm\node_modules\angular-cli\tasks\test.js:25:31 at Class.exports.default.Task.extend.run (C:\Users\Elg\AppData\Roaming\npm\node_modules\angular-cli\tasks\test.js:15:16) at Class.TestCommand.extend.run (C:\Users\Elg\AppData\Roaming\npm\node_modules\angular-cli\commands\test.js:26:25) at Class.<anonymous> (C:\Users\Elg\AppData\Roaming\npm\node_modules\angular-cli\node_modules\angular-cli\lib\models\command.js:152:17) at tryCatch (C:\Users\Elg\AppData\Roaming\npm\node_modules\angular-cli\node_modules\rsvp\dist\lib\rsvp-internal.js:215:12) at invokeCallback (C:\Users\Elg\AppData\Roaming\npm\node_modules\angular-cli\node_modules\rsvp\dist\lib\rsvp-internal.js:230:13)

at C:\Users\Elg\AppData\Roaming\npm\node_modules\angular-cli\node_modules\rsvp\dist\lib\rsvp\then.js:29:16
at flush (C:\Users\Elg\AppData\Roaming\npm\node_modules\angular-cli\node_modules\rsvp\dist\lib\rsvp\asap.js:85:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9) code: 'MODULE_NOT_FOUND' }

Mention any other details that might be useful.


Thanks! We’ll be in touch soon.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

65reactions
softgandhicommented, Mar 1, 2017

Hi, When I updated from angular-cli to @angular/cli, i also faced the same issue: Error: Cannot find module 'angular-cli/plugins/karma'

The solution worked for me is to update the karma.conf.js file present in root folder of the project.

frameworks: ['jasmine', '@angular/cli'],
...
plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-remap-istanbul'),
      require('@angular/cli/plugins/karma')
    ],
...
preprocessors: {
      './src/test.ts': ['@angular/cli']
    },
...

After this change, ng test should work.

46reactions
juhapcommented, Feb 5, 2017

Check if angular-cli/plugins/karma exists in the node_modules directory.

In my case the problem was that I had migrated to @angular/cli package, but karma.conf.js was still referencing the angular-cli paths. I updated my references by comparing to the karma.conf.js from this repo: https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/blueprints/ng2/files/karma.conf.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ng test throws an error Cannot find module 'angular-cli ...
in your karma.config.js file. ... Open your karma.conf.js file and replace every angular-cli/plugins/karma with: @angular/cli/plugins/karma.
Read more >
karma-runner/karma - Gitter
test cannot run and I'm getting module not found errors for two karma modules that ... require('@angular/cli/plugins/karma') ], client:{ clearContext: false ...
Read more >
Cannot find module error when running Karma tests in EAP 7
When I run or debug karma tests (which work fine from command line), I get an error about a missing intellijCli.js module.
Read more >
error in config file! error: cannot find module 'karma-coverage'
You need to change @angular-cli to @angular/cli in all the occurences. Hope this helps! Open side panel. ng test | An unhandled ...
Read more >
Cannot find module '@angular-devkit/build-angular ... - YouTube
An unhandled exception occurred: Cannot find module '@ angular -devkit/build- angular /package.json'The above exception while running an angular ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found