无法在Vagrant盒子Ubuntu 12.04中使用Karma启动Chrome/无法启动Firefox错误 [英] Cannot start Chrome / Cannot start Firefox errors with Karma in Vagrant box Ubuntu 12.04

查看:313
本文介绍了无法在Vagrant盒子Ubuntu 12.04中使用Karma启动Chrome/无法启动Firefox错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 https://docs.angularjs.org/tutorial/step_02 上关注Angular教程. a>.

I am following the Angular Tutorial at https://docs.angularjs.org/tutorial/step_02.

我要运行以下命令:

npm test
karma start karma.conf.js

并出现以下错误:

> karma start karma.conf.js

WARN [watcher]: Pattern "/var/angularapp/angular-phonecat/app/**/*.module.js" does not match any file.
WARN [watcher]: Pattern "/var/angularapp/angular-phonecat/app/!(bower_components)/**/*!(.module|.spec).js" does not match any file.
WARN [karma]: No captured browser, open http://localhost:9876/
INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
INFO [launcher]: Starting browser Firefox
INFO [launcher]: Starting browser Chrome
ERROR [launcher]: Cannot start Firefox

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

INFO [launcher]: Trying to start Firefox again (2/2).
17 08 2016 18:46:51.434:ERROR [launcher]: Cannot start Firefox

ERROR [launcher]: Firefox failed 2 times (cannot start). Giving up.
ERROR [launcher]: Cannot start Chrome

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

[launcher]: Trying to start Chrome again (2/2).
[launcher]: Cannot start Chrome

ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.

karma.config.js:

karma.config.js:

browsers: ['Firefox', 'Chrome'],

我使用以下命令安装了Firefox和Chrome:

I installed Firefox and Chrome using the following commands:

 sudo apt-install chromium-browser
 sudo apt-install firefox

并在〜/.bachrc中设置环境变量:

And set the env variables in ~/.bachrc:

export FIREFOX_BIN=/usr/bin/firefox
export CHROME_BIN=/usr/bin/chromium-browser

我什至键入了以下命令,但没有帮助:

I even typed the following command, but did not help:

source ~/.bashrc

我的节点版本是0.12.15,npm是2.15.1.请注意,这是我正在谈论的无聊的盒子.

My node version is 0.12.15 and npm is 2.15.1. Please note that this is a vagrant box that I am talking about.

请帮助:)

推荐答案

有人建议我改用Phantomjs!所以我做到了,下面是我所做的,并通过了测试:

Someone suggested that I should use Phantomjs instead! So I did it and below is what I did exactly and made the test pass:

安装PhantomJS:

Install PhantomJS:

sudo npm install -g phantomjs-prebuilt

通过在〜/.bashrc中添加以下行来更新env变量:

Update the env variable by adding the following line to ~/.bashrc:

export PHANTOMJS_BIN=/usr/bin/phantomjs

将以下行添加到项目中package.json文件中的devdependencies:

Add the following line to devdependencies in package.json file within the project:

"karma-phantomjs-launcher": "^0.2.0",

将以下行添加到karma.config.js文件:

Add the following line to karma.config.js file:

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

最后将karma.config.js中的浏览器更改为:

And finally change the browsers in karma.config.js to be:

browsers: ['PhantomJS'],

但是,我仍然不知道为什么Chrome和Firefox不能正常工作,而Phantomjs可以做到这一点.我的看法是,我无所事事的盒子只是一台Ubuntu计算机,不应与其他任何计算机一样!如果有人向我解释原因,那就太好了.并且请认为我是新手.

However, I still do not know why Chrome and Firefox did not work, and Phantomjs did the job. The way I view it is my vagrant box is just an Ubuntu machine, and should not be different than any other machines! It would be great if someone explains to me the reasons. And please consider that I am a newbie.

这篇关于无法在Vagrant盒子Ubuntu 12.04中使用Karma启动Chrome/无法启动Firefox错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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