$ npm i puppeteer > puppeteer@14.1.1 install /home/gitlab-runner/builds/deaaa930/0/project-abc/node_modules/puppeteer > node install.js ERROR: Failed to set up Chromium r991974! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download. Error: connect ETIMEDOUT 172.217.31.16:443 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) { errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect', address: '172.217.31.16', port: 443 }
npm WARN notsup Unsupported engine for puppeteer@14.1.1: wanted: {"node":">=14.1.0"} (current: {"node":"12.22.7","npm":"6.14.15"}) npm WARN notsup Not compatible with your version of node/npm: puppeteer@14.1.1 npm WARN enoent ENOENT: no such file or directory, open '/home/gitlab-runner/builds/deaaa930/0/project-abc/package.json' npm WARN project-abc No description npm WARN project-abc No repository field. npm WARN project-abc No README data npm WARN project-abc No license field. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! puppeteer@14.1.1 install: `node install.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the puppeteer@14.1.1 install script.
看错误日志是在执行 npm i puppeteer 时出现失败,猜测是当时出现网络故障。
解决办法:实际上已经在 gitlab runner 所在的机器上全局安装过 puppeteer@14.1.1,且设置了 gitlab CI 缓存,所以没必要每次构建时都重新安装。.gitlab-ci.yml 优化如下。
$ ./bugly.sh "${IS_PRD}" (node:4711) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'waitForSelector' of undefined at /home/gitlab-runner/builds/deaaa930/0/project-abc/pp.js:33:17 at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:4711) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:4711) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. Session terminated, killing shell... ...killed. ERROR: Job failed: execution took longer than 1h0m0s seconds