Cannot install phantomJS in Karma

Deadly 提交于 2019-12-03 09:28:04

npm install karma-jasmine --save-dev

npm install karma-phantomjs-launcher --save-dev

Then add the following line to karma.config.js

plugins : ['karma-jasmine', 'karma-phantomjs-launcher']

I got tripped up by this today running

  • karma: 0.13.7
  • karma-phantomjs-launcher: 1.0.0

What isn't very obvious is that the launcher has a dependency on:

  • phantomjs-prebuilt

So if you, install this locally everything should run fine, eg:

npm install phantomjs-prebuilt --save-dev

After some research I realized that I needed to run:

npm install -g karma@canary phantomjs karma-phantomjs-launcher

Once I ran that I went back into my karma-unit.tpl.js file and instead of karma-phantomjs, I changed this to karma-phantomjs-launcher.

Now when I execute a command like grunt build, I get no error regarding phantomJS

This is an issue still open on the repo: #31

Strangely enough the following worked for my Debian based system:

apt-get install libfontconfig

How did I get into this? Reading a comment from the ticket. Hope this will help for others too :-)

I'm running in a CentOS 7 Docker container. Had similar issue.

Had to:

yum install -y tar bzip2 freetype fontconfig

Then

npm install phantomjs --save-dev

worked without errors, which allowed

npm install karma-phantomjs-launcher --save-dev

and that allowed

gulp test

to run without Karma or PhantomJS errors.

Today I had the same. I deleted all the temporary directories and, after rerun it worked. Before that i also reinstalled phantomjs but without success. It's possible that this influenced, anyway (but i think deleting the temporary directories did the job). Anyway, after deleting temporary folders you can try, if it didn't work you can reinstall phantomjs and also other stuff as other users already wrote.

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