【问题标题】:When running karma locally, phantomjs won't start在本地运行 karma 时,phantomjs 不会启动
【发布时间】:2015-05-16 04:30:09
【问题描述】:

在我的 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 上运行良好(我在运行之前删除了 karma 的全局安装,它仍然有效)。

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

这是外壳输出:

> ./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 手动启动节点服务器,所以这也可能不是问题。

任何帮助将不胜感激。谢谢!

----更新

我创建了一个新的 Ubuntu 环境并再次测试了相同的东西并得到了相同的错误。

【问题讨论】:

  • 我遇到了类似的问题,但exit code 1
  • 根据我之前的评论,通过从项目中删除node_modules 目录(已由其他人使用 Macbook)。我再次运行npm install 并重新创建了node_modules 目录。我们还将node_modules 目录添加到.gitignore 以避免将来出现此问题。
  • 有趣,有机会我一定要再试一次。我在 Mac 主机上使用 Vagrant,这样就可以解释了。稍后我会在测试时发布结果。
  • 如果与Mac Os Sierra相关,请将版本改为1.0.0或以上

标签: phantomjs karma-runner ubuntu-14.04


【解决方案1】:

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

【讨论】:

  • 在再次运行 npm install 之前不要忘记删除 node_modules 中的 karma-phantomjs-launcher...
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    我遇到了同样的问题,对我有用的解决方案是运行 sudo yum install fontconfig , 该命令必须在正确的位置执行,但这有效..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2016-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多