angular-cli: Error in config file : Cannot find module 'angular-cli/plugins/karma'
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.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 8
- Comments: 18 (2 by maintainers)
Commits related to this issue
- update karma.conf to usage of @angular/cli thanks to https://github.com/angular/angular-cli/issues/2828#issuecomment-277516876 — committed to etwillbefine/angular2-seed by etwillbefine 7 years ago
- Fix Karma test setup so tests can run There currently aren't any tests, but it looks like it works. See https://github.com/angular/angular-cli/issues/2828. — committed to woven-teams/yatrum by panozzaj 7 years ago
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.
After this change, ng test should work.
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
@frank-productops New link you can check out: https://github.com/angular/angular-cli/blob/b15d1f37b6c6d7e57d969359b8b7d8a916465362/packages/%40angular/cli/blueprints/ng/files/karma.conf.js
@juhap It seems that your link is broken. Could you take a look and fix it please? I’m also having a similar issue.
Since Google highly prefers Github issues instead of StackOverflow when it comes to debugging Angular 2 applications, I figured I would chime in here.
The issue is that the Node package for Angular’s CLI was changed from
angular-cli
to@angular/cli
. If you go through yourkarma.conf.js
file and replace all instances ofangular-cli
with@angular/cli
you should be good to go.Shout out to this StackOverflow post that got me to the correct answer. Also shout out to @softgandhi for answering the same thing. Unfortunately for him I lack reading comprehension.
Detailed guide on needed changes to
karma.conf.js
after upgrading to @angular/cli rc1: https://github.com/angular/angular-cli/wiki/stories-rc.0-updateHi,
I’m experiencing the same issue -> fresh node and angular-cli installation, everything works, just the ng test doesn’t (same error message and no karma plugin found).
angular-cli: 1.0.0-beta.18 node: 6.9.1 os: win32 x64
Cheers
I had a project in angular2, primeng and angular-cli. I decided to migrate angular4 and @ angular-cli When with the own guide angular but I did not work out errors when finding the core module. Then I decided to create a new project with the new @ angular-cli and pass the source code, there were errors where we had to add the Angular animations module and update Primeng. Work for me.