幻影无法启动 [英] phantomjs cannot start up

查看:188
本文介绍了幻影无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目和业力中使用AngularJS进行测试。然后我配置了这样的业力:

I used AngularJS in my project and karma to test. Then I configured karma like this:

config.set({
    basePath: '../',
    frameworks: ['jasmine'],
    files: [
        // bower:js
        'bower_components/jquery/dist/jquery.js',
        'bower_components/angular/angular.js',
        'bower_components/bootstrap/dist/js/bootstrap.js',
        'bower_components/angular-animate/angular-animate.js',
        'bower_components/angular-cookies/angular-cookies.js',
        'bower_components/angular-route/angular-route.js',
        'bower_components/angular-sanitize/angular-sanitize.js',
        'bower_components/angular-mocks/angular-mocks.js',
        // endbower
        'js/**/*.js',
        'test/spec/**/*.js'
    ],
    browsers: [
        'PhantomJS'
    ],
    plugins: [
        'karma-phantomjs-launcher',
        'karma-jasmine'
    ],
    port: 8890

})

像这样的咕噜声:

And grunt like this:

grunt.initConfig({
    connect: {
        testserver: {
            options: {
                base: 'js/',
                hostname: 'localhost',
                port: '8889'
            }
        }
    },
    karma: {
        unit: {
            configFile: './test/karma-unit.conf.js',
            singleRun: true
        }
    } 
});

grunt.registerTask('test', ['connect', 'karma:unit']);

当我输入'grunt test'时,控制台显示phantomjs无法启动:

When I type 'grunt test', the console shows that phantomjs cannot start:

Running "connect:testserver" (connect) task
Started connect web server on http://localhost:8889

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.31 server started at http://localhost:8890/
INFO [launcher]: Starting browser PhantomJS
ERROR [launcher]: Cannot start PhantomJS

INFO [launcher]: Trying to start PhantomJS again (1/2).
ERROR [launcher]: Cannot start PhantomJS

INFO [launcher]: Trying to start PhantomJS again (2/2).
ERROR [launcher]: Cannot start PhantomJS

ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.
Warning: Task "karma:unit" failed. Use --force to continue.

Aborted due to warnings.

我该如何解决这个问题?任何人都可以帮我吗?

How can I solve this? Can anybody help me?

推荐答案

我也遇到过这个问题,似乎是karma-phantomjs2-launcher寻找的问题phantomjs可执行文件。它使用PHANTOMJS_BIN来运行phantomjs,所以我解决了这个问题:

I ran into this too, seemed to be an issue with where karma-phantomjs2-launcher looks for the phantomjs executable. It uses PHANTOMJS_BIN to run phantomjs, so I solved it like this:

export PHANTOMJS_BIN=/usr/local/bin/phantomjs

只要您可以从命令行运行phantomjs,它也可以运行,它。

As long as you can run "phantomjs" from the command line too and it works, that should probably do it.

这篇关于幻影无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆