phantomjs - 在本地运行 karma 时,phantomjs 无法启动

标签 phantomjs karma-runner ubuntu-14.04

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

版本信息:

  • PhantomJS(也在本地安装):1.9.16
  • karma :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,它启动得很好。

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

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

    - - 更新

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

    最佳答案

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

    关于phantomjs - 在本地运行 karma 时,phantomjs 无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29036510/

    相关文章:

    javascript - phantomjs 使用 formurlencoded 发布请求

    javascript - 在 CapserJS 中操作 http 响应正文

    javascript - 是否可以在 Protractor 中单击带有 phantomJS 的元素?

    webpack - 如何将 webpack 多个条目与 karma 一起使用?

    python - 在 Ubuntu Linux 上运行一个 python 文件

    javascript - Phantom.js 登录 instagram 页面

    javascript - 期望不带参数的 toThrow 函数 - Jasmine

    firefox - 如何使用 Xvfb 在 Firefox 中运行 Karma?

    当存在多个虚拟主机标签 Ubuntu14.04 时,Apache 2.4.7 重定向不起作用

    hadoop - Hadoop没有看到输入文件夹