gpt4 book ai didi

gruntjs - phantomjs无法启动

转载 作者:行者123 更新时间:2023-12-02 15:24:34 26 4
gpt4 key购买 nike

我在我的项目和karma中使用了AngularJS来测试。然后我这样配置 karma :

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

})

像这样 Grunt :

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 无法启动:

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.

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

最佳答案

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

export PHANTOMJS_BIN=/usr/local/bin/phantomjs

只要您也可以从命令行运行“phantomjs”并且它可以工作,那么应该可以做到。

关于gruntjs - phantomjs无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28876061/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com