在本地运行业力时,phantomjs将无法启动

时间:2015-03-13 15:46:25

标签: phantomjs karma-runner ubuntu-14.04

当我的Ubuntu VM上的项目本地安装运行Karma时,Karma将无法运行,因为PhantomJS无法启动。

版本信息:

  • PhantomJS(也在本地安装):1.9.16
  • 业力:0.12.31
  • karma-phantomjs-launcher:0.1.4
  • Ubuntu 14.04.2 LTS
  • 节点0.10.25

同样的脚本在我的Mac OS上运行得很好(我在运行它之前删除了全局的业力安装,它仍然有用)。

在Ubuntu上,如果我直接通过./node_modules/phantomjs/bin/phantomjs启动phantomjs,它就会正常启动。

这是shell输出:

> ./node_modules/karma/bin/karma start test/karma.conf.js

DEBUG [config]: autoWatch set to false, because of singleRun
DEBUG [plugin]: Loading karma-* from /srv/detectiveui/node_modules
DEBUG [plugin]: Loading plugin /srv/detectiveui/node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin /srv/detectiveui/node_modules/karma-phantomjs-launcher.
DEBUG [plugin]: Loading plugin /srv/detectiveui/node_modules/karma-spec-reporter.
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-42625347
DEBUG [launcher]: /srv/detectiveui/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-42625347/capture.js
DEBUG [launcher]: Process PhantomJS exited with code 2
ERROR [launcher]: Cannot start PhantomJS

DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-42625347
INFO [launcher]: Trying to start PhantomJS again (1/2).
DEBUG [launcher]: Restarting PhantomJS
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-42625347
DEBUG [launcher]: /srv/detectiveui/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-42625347/capture.js /tmp/karma-42625347/capture.js
DEBUG [watcher]: Resolved files:
    #...List of my files here that look correct...
DEBUG [launcher]: Process PhantomJS exited with code 2
ERROR [launcher]: Cannot start PhantomJS

DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-42625347
INFO [launcher]: Trying to start PhantomJS again (2/2).
DEBUG [launcher]: Restarting PhantomJS
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-42625347
DEBUG [launcher]: /srv/detectiveui/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs /tmp/karma-42625347/capture.js /tmp/karma-42625347/capture.js /tmp/karma-42625347/capture.js
DEBUG [launcher]: Process PhantomJS exited with code 2
ERROR [launcher]: Cannot start PhantomJS

DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-42625347
ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.

DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers

我似乎也能够在端口9876手动启动节点服务器,所以这可能也不是问题。

非常感谢任何帮助。谢谢!

---- UPDATE

我创建了一个新的Ubuntu环境并再次测试了同样的事情并得到了同样的错误。

3 个答案:

答案 0 :(得分:3)

我遇到了同样的问题,我将karma-phantomjs-launcher更改为package.json文件中的“^ 1.0.0”。 改变后,Phantomjs开始工作

答案 1 :(得分:1)

通过libfontconfig安装sudo apt-get install libfontconfig可以解决此问题。

答案 2 :(得分:1)

我遇到了同样的问题,对我有用的解决方案就是运行     {{1}}, 该命令必须在正确的位置执行,但这有效。