我们正在将基于Angular(Angular, NgRx and Angular Material Starter)的网站从CircleCI迁移到Shippable,现在我遇到了以下失败:
27 05 2019 14:46:00.036:INFO [karma-server]: Karma v4.0.1 server started at http://0.0.0.0:9876/
27 05 2019 14:46:00.040:INFO [launcher]: Launching browsers ChromeShippable with concurrency unlimited
27 05 2019 14:46:00.071:INFO [launcher]: Starting browser Chrome
27 05 2019 14:46:01.326:ERROR [launcher]: Cannot start Chrome
nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/build/versions/node/v10.14.1"
Run `unset npm_config_prefix` to unset it.
27 05 2019 14:46:01.327:ERROR [launcher]: Chrome stdout:
27 05 2019 14:46:01.327:ERROR [launcher]: Chrome stderr: nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/build/versions/node/v10.14.1"
Run `unset npm_config_prefix` to unset it.
我可以共享更多配置,但是相同的代码在CircleCI中构建良好,但现在在Shippable中失败了。
我可以使用drydock/u16nodall
映像在本地(在本地Docker上)复制。
我们在运行npm之前设置以下环境变量:
export PATH="./node_modules/.bin:$PATH";
export CHROME_BIN=chromium-browser;
export DISPLAY=:99.0;
不同的NPM或Node版本似乎没有什么不同。
karma.conf.js
具有此功能:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
var isWatch = config.buildWebpack.options.watch;
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-spec-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../shippable/codecoverage'),
reports: ['cobertura', 'html', 'lcovonly', 'json'],
fixWebpackSourcePaths: true,
thresholds: {
statements: 80,
lines: 80,
branches: 72,
functions: 80
}
},
reporters: ['spec'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
ChromeShippable: {
base: 'Chrome',
flags: ['--no-sandbox','--disable-setuid-sandbox']
}
},
browserNoActivityTimeout: 50000,
singleRun: !isWatch
});
};
我所能找到的所有与_不兼容的npm_config_prefix_错误有关的错误似乎与损坏的节点安装有关。但是,使用NVM安装新版本也会显示此错误。
有什么想法可以使它正常工作吗?
答案 0 :(得分:0)
我终于能够通过将customLauchers
配置更新为基于ChromeHeadless
而非Chrome
的配置来克服此问题。
customLaunchers: {
ChromeShippable: {
base: 'ChromeHeadless',
flags: ['--no-sandbox','--disable-setuid-sandbox']
}
},
我还没有在可移植的迁移中追逐错误,但是至少这可以清除我具体询问的错误。我已经确认在Shippable构建框中也可以正常运行(启动Chrome时也不会崩溃)。
编辑:所有随后的大多数错误也与需要显式运行Chrome的情况有关。
已添加到.pa11yci
的{{1}}:
defaults
已添加到"chromeLaunchConfig": {
"args": ["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"]
}
导出的e2e/protractor.conf.js
中:
capabilities
此问题范围之外还有许多其他更改。