Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yeoman, Angular Generator, and Karma Test not working

I'm trying to use Yeoman with the angular-generator to start a new application.

I run this command (according to the docs) to start a new app:

yo angular my-app-name

All dependencies have been download and if I run

grunt serve

my base app shows up in browser and everything look to work fine. The problem starts when I try to run:

grunt test

I get an error : Warning: Task "karma" not found. Use --force to continue.

So I've added these line:

"grunt-karma": "*",
"generator-karma": "*"

in my packeage.json file, remove the node_modules folder and runned `npm install. I was hping to solving the issue but now i get the error:

loading "grunt-karma.js" tasks...ERROR
>> Error: Cannot find module 'socket.io-client'
Warning: Task "karma" not found. Use --force to continue.

Aborted due to warnings.

I've tried to google a bit but I can't find anything about. I'm running MacOsX 10.8.5 and node v0.10.0 . Any suggestion?

Thanks in advance

like image 414
teone Avatar asked Mar 21 '23 13:03

teone


1 Answers

There have been problems with Karma and angular-generator. Are you running the latest version of the generator?

Not sure what caused the failure, but sometimes there are issues installing karma dependencies. Try running:

npm install grunt-karma karma-ng-html2js-preprocessor karma-ng-scenario --save-dev 

And if that doesn't work then workaround you can use for now is to add the following dependencies to your package.json after it failed installing:

"karma-ng-scenario": "~0.1.0",
"grunt-karma": "~0.6.2",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.2",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.5",
"requirejs": "~2.1.9",
"karma-requirejs": "~0.2.1",
"karma-coffee-preprocessor": "~0.1.1",
"karma-phantomjs-launcher": "~0.1.1",
"karma": "~0.10.8",
"karma-ng-html2js-preprocessor": "~0.1.0"

Then run npm install again.

like image 87
Darryl Snow Avatar answered Mar 28 '23 23:03

Darryl Snow