Continuous integration travis:sh:0:Can';t打开/etc/init.d/xvfb

Continuous integration travis:sh:0:Can';t打开/etc/init.d/xvfb,continuous-integration,ubuntu-16.04,travis-ci,Continuous Integration,Ubuntu 16.04,Travis Ci,我的travis CI使用Ubuntu 14.04和Node.js 8。我的.travis.yml看起来像: language: node_js node_js: - 8 sudo: required addons: chrome: stable before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start install: - npm set progress=false - npm ins

我的travis CI使用Ubuntu 14.04和Node.js 8。我的
.travis.yml
看起来像:

language: node_js
node_js:
  - 8
sudo: required
addons:
    chrome: stable
before_script:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start
install:
  - npm set progress=false
  - npm install
script:
  - ng lint
  - npm run test
  - npm run e2e
  - npm run build
我尝试将其更新为使用Ubuntu 16.04和Node.js 10,方法是将其更改为:

language: node_js
node_js:
  - '10'
dist: xenial
sudo: required
addons:
    chrome: stable
before_script:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start
install:
  - npm set progress=false
  - npm install
script:
  - ng lint
  - npm run test
  - npm run e2e
  - npm run build
但是现在我在尝试启动
xvfb
时出错:

0.00s$sh-e/etc/init.d/xvfb启动

sh:0:无法打开/etc/init.d/xvfb

命令“sh-e/etc/init.d/xvfb start”失败,并在执行过程中以127退出


解决方案是从
before_脚本
数组中删除
sh-e/etc/init.d/xvfb start
,并在
服务
数组中简单引入
xvfb

所以我的
.travis.yml
现在看起来像这样:

language: node_js
node_js:
  - '10'
dist: xenial
sudo: required
services:
  - xvfb
addons:
    chrome: stable
before_script:
  - export DISPLAY=:99.0
install:
  - npm set progress=false
  - npm install
script:
  - ng lint
  - npm run test
  - npm run e2e
  - npm run build

除了公认的答案之外,我想说的是,根据travis docs,结果配置应该更清晰一些。您不需要设置
显示
,因此
在脚本
部分变得过多之前:

这只适用于Ubuntu 16.04(Xenial)和更高版本,即dist:Xenial或dist:bionic
下面将启动xvfb并为DISPLAY环境变量设置正确的值

此外,您不需要在2019年为node_js指定dist,因为
xenial
node_js
语言now()的默认图像。以前它是
trusty
,因此另一种可能的解决方案可能是将dist指定为
trusty
(请参阅)。但说到默认设置,所讨论的配置可能如下

language: node_js
node_js:
  - '10'
sudo: required
services:
  - xvfb
addons:
    chrome: stable
install:
  - npm set progress=false
  - npm install
script:
  - ng lint
  - npm run test
  - npm run e2e
  - npm run build

是的,只是忘了做那件事。谢谢