【问题标题】:Cannot install phantomJS in Karma无法在 Karma 中安装 phantomJS
【发布时间】:2013-09-02 15:42:18
【问题描述】:
WARN [config]: config.configure() is deprecated, please use config.set() instead.
WARN [plugin]: Cannot find plugin "karma-phantomjs".
  Did you forget to install it ?
  npm install karma-phantomjs --save-dev
INFO [karma]: Karma v0.10.2 server started at http://localhost:9018/
WARN [launcher]: Can not load "PhantomJS", it is not registered!
  Perhaps you are missing some plugin?

收到此错误。运行 npm install karma-phantomjs --save-dev 时出现错误。

npm ERR! 404 'karma-phantomjs' is not in the npm registry.

我安装了 karma-phantomjs-launcher --save-dev 但在运行 grunt watch 时仍然出现错误。

还有其他人遇到过这个问题吗?

【问题讨论】:

  • @karma-phantomjs@ 在 npm-registry 中根本不存在,@karma-phantomjs-launcher@ 出现的错误是什么?显示您的 gruntfile 也会有所帮助...
  • 我在这里添加了我的 Gruntfile:pastebin.com/gzmcRSKF karma-phantomjs-launcher 安装得非常好。我没有错误。但是,当我运行 grunt watch 时,我仍然收到有关 phantomJS 的错误。当运行 phantomjs --version 我得到 1.9.1 的回报。

标签: phantomjs gruntjs karma-runner


【解决方案1】:

经过一番研究,我意识到我需要跑步:

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

运行后,我回到了我的 karma-unit.tpl.js 文件,而不是 karma-phantomjs,我将其更改为 karma-phantomjs-launcher。

现在当我执行像 grunt build 这样的命令时,我没有收到关于 phantomJS 的错误

【讨论】:

    【解决方案2】:

    npm install karma-jasmine --save-dev

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

    然后将以下行添加到 karma.config.js

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

    【讨论】:

    【解决方案3】:

    这是一个在 repo 上仍然存在的问题:#31

    奇怪的是,以下内容适用于我的基于 Debian 的系统:

    apt-get install libfontconfig
    

    我是怎么接触到这个的?从票证中读取comment。希望这对其他人也有帮助:-)

    【讨论】:

      【解决方案4】:

      我今天跑步被这个绊倒了

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

      不太明显的是启动器依赖于:

      • phantomjs-prebuilt

      因此,如果您在本地安装它,一切都应该运行良好,例如:

      npm install phantomjs-prebuilt --save-dev

      【讨论】:

      • 它解决了我的问题。奇怪的是这个依赖没有和启动器模块一起安装
      【解决方案5】:

      我在 CentOS 7 Docker 容器中运行。有类似的问题。

      不得不:

      yum install -y tar bzip2 freetype fontconfig
      

      然后

      npm install phantomjs --save-dev
      

      工作没有错误,这允许

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

      这允许

      gulp test
      

      在没有 Karma 或 PhantomJS 错误的情况下运行。

      【讨论】:

      • 倒数第二个命令应该是npm install karma-phantom-js-launcher --save-dev吗?
      • @meatspace 谢谢,已修复,但您的文件中有多余的“-”:)
      【解决方案6】:

      今天我也一样。我删除了所有临时目录,重新运行后它起作用了。 在此之前,我还重新安装了 phantomjs,但没有成功。无论如何,这可能会受到影响(但我认为删除临时目录可以完成这项工作)。无论如何,删除临时文件夹后,您可以尝试,如果它不起作用,您可以重新安装 phantomjs 以及其他用户已经写过的其他东西。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-07-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-01
        • 2016-12-27
        • 2016-09-11
        • 1970-01-01
        • 2017-12-22
        相关资源
        最近更新 更多