我有一个带有单元和 e2e 测试的 stenciljs 项目,可以在本地完美运行,但在服务器上失败并出现给定错误:
启动 chrome 失败!spawn /builds/header/node_modules/puppeteer/.local-chromium/linux-588429/chrome-linux/chrome ENOENT 疑难解答: https ://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md 错误:启动 chrome 失败!spawn /builds/header/node_modules/puppeteer/.local-chromium/linux-588429/chrome-linux/chrome ENOENT 疑难解答: https ://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md 在 onClose (/builds/header/node_modules/puppeteer/lib/Launcher.js:333:14) 在 ChildProcess.helper.addEventListener.error (/builds/header/node_modules/puppeteer/lib/Launcher.js:324:64)在 ChildProcess.emit (events.js:182:13) 在 Process.ChildProcess._handle.onexit (internal/child_process.js:238:12) 在 onErrorNT (internal/child_process.js:407:16) 在 process._tickCallback (内部/进程/next_tick.js:63:19)
包.json:
...
"scripts": {
...
"e2e": "stencil test --e2e",
...
},
,
"dependencies": {
"@stencil/core": "^0.15.2",
"@stencil/sass": "^0.1.1",
"ionicons": "^4.4.6"
},
"devDependencies": {
"@stencil/dev-server": "0.0.18",
"@stencil/utils": "latest",
"@types/jest": "23.3.4",
"@types/node": "10.5.3",
"@types/puppeteer": "1.6.0",
"jest": "23.5.0",
"license-checker": "^24.0.1",
"mocky": "^0.1.11",
"npm-run-all": "^4.1.5",
"pixelmatch": "4.0.2",
"puppeteer": "1.7.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"workbox-build": "3.4.1"
}
正在使用 gitlab runner 运行构建,当我搜索解决方案时,我发现 puppeteer (v1.8.0) 的较新版本是有这个问题的,所以我在我的 package.josn 中将它修复为 1.7.0但它在测试执行期间正在更新:
模板测试--e2e
[28:43.7] 正在更新所需的依赖项,请稍候。这可能需要一些时间,并且仅在初始运行时需要。[28:43.7] 安装依赖项:jest-cli、@types/puppeteer、jest、puppeteer ... npm WARN 已弃用 kleur@2.0.2:如果您愿意,请升级到 kleur@3 或迁移到“ansi-colors”旧语法。访问https://github.com/lukeed/kleur/releases/tag/v3.0.0\了解迁移路径。
puppeteer@1.8.0 install /builds/header/node_modules/puppeteer node install.js
Chromium 下载到 /builds/header/node_modules/puppeteer/.local-chromium/linux-588429
- 开玩笑@23.6.0
- jest-cli@23.6.0
- puppeteer@1.8.0
- @types/puppeteer@1.11.2 添加了 1 个包,删除了 17 个包,更新了 23 个包并在 50.353 秒内移动了 23 个包 [29:34.7] 安装依赖项在 51.00 秒内完成