generator-angular: task “karma” not found when calling `grunt test`

我们两清 提交于 2019-12-02 18:47:05
npm install grunt-karma --save-dev

or if you need it

sudo npm install grunt-karma --save-dev

from the docs on https://npmjs.org/package/grunt-karma

after running

npm install grunt-karma --save-dev

add the following line to Gruntfile.js

grunt.loadNpmTasks('grunt-karma');

this works for me.

The obvious answers already posted here were completely unhelpful to me. If reinstalling grunt-karma via npm didn't work, and explicitly loading the task in the Gruntfile didn't help, you may be running a version of npm prior to 1.2.10.

It turns out that recent versions of grunt-karma rely on peer dependencies, which were introduced to Node with version 8.19. After upgrading Nodejs (which also installs npm) and upgrading karma globally, I discovered I needed to edit my karma config files as well. You'll want to add frameworks: ['jasmine'], to karma.conf.js and remove references to JASMINE and JASMINE_ADAPTER from the files setting.

A was having the problem of Not Found.

Finally I realize it was a problem with the port (8080 was already used)

in karma.config.js change the port number:

// web server port
port: 9999,
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!