cnpm / cnpmcore

Private NPM Registry for Enterprise
https://npmmirror.com
MIT License
573 stars 78 forks source link

puppeteer 安装失败 #652

Closed crazyair closed 4 months ago

crazyair commented 4 months ago
  1. clone https://github.com/crazyair/puppeteer-install
  2. npm i
github-actions[bot] commented 4 months ago

我们已经看到你的反馈,如果是功能缺陷,可以提供一下重现该问题的方式;如果是新功能需求,我们会尽快加入讨论。同时我们非常期待你可以加入我们的贡献者行列,让项目可以长期可持续发展。

elrrrrrrr commented 4 months ago

@crazyair 本地没能重现报错,麻烦补充下报错哈

是需要用 cnpm 来进行安装? 二进制产物除了 registry 配置外,还要用独立客户端配置对应环境变量

crazyair commented 4 months ago
npm i 
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@puppeteer/browsers@2.1.0',
npm WARN EBADENGINE   required: { node: '>=18' },
npm WARN EBADENGINE   current: { node: 'v16.20.2', npm: '8.19.4' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'puppeteer@22.2.0',
npm WARN EBADENGINE   required: { node: '>=18' },
npm WARN EBADENGINE   current: { node: 'v16.20.2', npm: '8.19.4' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'puppeteer-core@22.2.0',
npm WARN EBADENGINE   required: { node: '>=18' },
npm WARN EBADENGINE   current: { node: 'v16.20.2', npm: '8.19.4' }
npm WARN EBADENGINE }
npm ERR! code 1
npm ERR! path /Users/crazyair/test/puppeteer-install/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c -- node install.mjs
npm ERR! Error: ERROR: Failed to set up Chrome v123.0.6301.2! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
npm ERR!     at file:///Users/crazyair/test/puppeteer-install/node_modules/puppeteer/lib/esm/puppeteer/node/install.js:58:23
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm ERR!     at async Promise.all (index 0)
npm ERR!     at async downloadBrowser (file:///Users/crazyair/test/puppeteer-install/node_modules/puppeteer/lib/esm/puppeteer/node/install.js:90:9) {
npm ERR!   [cause]: Error: The browser folder (/Users/crazyair/.cache/puppeteer/chrome/mac_arm-123.0.6301.2) exists but the executable (/Users/crazyair/.cache/puppeteer/chrome/mac_arm-123.0.6301.2/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing) is missing
npm ERR!       at installUrl (file:///Users/crazyair/test/puppeteer-install/node_modules/@puppeteer/browsers/lib/esm/install.js:109:23)
npm ERR!       at install (file:///Users/crazyair/test/puppeteer-install/node_modules/@puppeteer/browsers/lib/esm/install.js:72:34)
npm ERR!       at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm ERR!       at async Promise.all (index 0)
npm ERR!       at async downloadBrowser (file:///Users/crazyair/test/puppeteer-install/node_modules/puppeteer/lib/esm/puppeteer/node/install.js:90:9)
npm ERR! }

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/crazyair/.npm/_logs/2024-02-23T05_56_59_064Z-debug-0.log
crazyair commented 4 months ago
 cnpm i 
⠴ [0/1] Installing puppeteer@^22.2.0
WARN node unsupported "node@v16.20.2" is incompatible with puppeteer@^22.2.0, expected node@>=18
⠹ [0/1] Installing argparse@^2.0.1
WARN node unsupported "node@v16.20.2" is incompatible with puppeteer@22.2.0 › @puppeteer/browsers@2.1.0, expected node@>=18
⠇ [0/1] Installing socks-proxy-agent@^8.0.2
WARN node unsupported "node@v16.20.2" is incompatible with puppeteer@22.2.0 › puppeteer-core@22.2.0, expected node@>=18
✔ Installed 1 packages
✔ Linked 114 latest versions
[1/1] scripts.postinstall puppeteer@^22.2.0 run "node install.mjs", root: "/Users/crazyair/test/puppeteer-install/node_modules/_puppeteer@22.2.0@puppeteer"
PUPPETEER_DOWNLOAD_HOST is deprecated. Use PUPPETEER_DOWNLOAD_BASE_URL instead.
chrome-headless-shell (122.0.6261.57) downloaded to /Users/crazyair/.cache/puppeteer/chrome-headless-shell/mac_arm-122.0.6261.57
Error: ERROR: Failed to set up Chrome v122.0.6261.57! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
    at file:///Users/crazyair/test/puppeteer-install/node_modules/_puppeteer@22.2.0@puppeteer/lib/esm/puppeteer/node/install.js:58:23
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    at async downloadBrowser (file:///Users/crazyair/test/puppeteer-install/node_modules/_puppeteer@22.2.0@puppeteer/lib/esm/puppeteer/node/install.js:90:9) {
  [cause]: Error: The browser folder (/Users/crazyair/.cache/puppeteer/chrome/mac_arm-122.0.6261.57) exists but the executable (/Users/crazyair/.cache/puppeteer/chrome/mac_arm-122.0.6261.57/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing) is missing
      at installUrl (file:///Users/crazyair/test/puppeteer-install/node_modules/_@puppeteer_browsers@2.1.0@@puppeteer/browsers/lib/esm/install.js:109:23)
      at install (file:///Users/crazyair/test/puppeteer-install/node_modules/_@puppeteer_browsers@2.1.0@@puppeteer/browsers/lib/esm/install.js:72:34)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async Promise.all (index 0)
      at async downloadBrowser (file:///Users/crazyair/test/puppeteer-install/node_modules/_puppeteer@22.2.0@puppeteer/lib/esm/puppeteer/node/install.js:90:9)
}
[npminstall:runscript:error] puppeteer@^22.2.0 scripts.postinstall run "node install.mjs" error: Error [RunScriptError]: Run "sh -c node install.mjs" error, exit code 1
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cnpm/node_modules/runscript/index.js:96:21)
    at ChildProcess.emit (node:events:513:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12) {
  stdio: [Object],
  exitcode: 1
}
✖ Install fail! RunScriptError: post install error, please remove node_modules before retry!
Run "sh -c node install.mjs" error, exit code 1
RunScriptError: Run "sh -c node install.mjs" error, exit code 1
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cnpm/node_modules/runscript/index.js:96:21)
    at ChildProcess.emit (node:events:513:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
npminstall version: 6.5.0
npminstall args: /Users/crazyair/.nvm/versions/node/v16.20.2/bin/node /usr/local/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js --fix-bug-versions --china --userconfig=/Users/crazyair/.cnpmrc --disturl=https://npmmirror.com/mirrors/node --registry=https://registry.npmmirror.com
crazyair commented 4 months ago

https://cdn.npmmirror.com/binaries/chrome-for-testing 这个地址怎么访问不了了

crazyair commented 4 months ago

要想重现,可以把本地已经下载好的 chrome 删除

crazyair commented 4 months ago

奇怪,可以用 pnpm 下载,pnpm 把浏览器下载完后,npm cnpm 就没问题了

 export PUPPETEER_BROWSER_REVISION=123.0.6301.2 & pnpm i 
[1] 14663
[1]  + 14663 done       export PUPPETEER_BROWSER_REVISION=123.0.6301.2 
Packages: +118
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
node_modules/.pnpm/puppeteer@22.2.0/node_modules/puppeteer: Running postinstall script, done in 8m 56.3s
Progress: resolved 118, reused 118, downloaded 0, added 0, done
hezhengxu2018 commented 4 months ago

binary会有本地的缓存,所以下载过一次之后就没问题了。应该和 #649 说的是同一个问题,正确的地址应该是https://registry.npmmirror.com/-/binary/chrome-for-testing/

fengmk2 commented 4 months ago

还没定位到问题,先打印一些日志看看。

fengmk2 commented 4 months ago

https://cnpmcore.oss-cn-hongkong.aliyuncs.com/binaries/chrome-for-testing/syncs/2024/02/240201-65d8dd7647346f59f6a6f73c.log 开始重新同步了。

crazyair commented 4 months ago

下载了 cnpm 可以用,用 npm i 还是直接报错

 cnpm i 
✔ Installed 1 packages
✔ Linked 114 latest versions
[1/1] scripts.postinstall puppeteer@^22.2.0 run "node install.mjs", root: "/Users/crazyair/test/puppeteer-install/node_modules/_puppeteer@22.2.0@puppeteer"
PUPPETEER_DOWNLOAD_HOST is deprecated. Use PUPPETEER_DOWNLOAD_BASE_URL instead.
Downloading chrome r123.0.6301.2 - 85.2 MB [====================] 100% 0.0s 
Downloading chrome r123.0.6301.2 - 147.9 MB [===============     ] 75% 10.3s chrome-headless-shell (123.0.6301.2) downloaded to /Users/crazyair/.cache/puppeteer/chrome-headless-shell/mac_arm-123.0.6301.2
Downloading chrome r123.0.6301.2 - 147.9 MB [====================] 100% 0.0s 
Chrome (123.0.6301.2) downloaded to /Users/crazyair/.cache/puppeteer/chrome/mac_arm-123.0.6301.2
[1/1] scripts.postinstall puppeteer@^22.2.0 finished in 41s
✔ Run 1 scripts
peerDependencies WARNING puppeteer@22.2.0 › puppeteer-core@22.2.0 › ws@8.16.0 requires a peer of bufferutil@^4.0.1 but none was installed
peerDependencies WARNING puppeteer@22.2.0 › cosmiconfig@9.0.0 requires a peer of typescript@>=4.9.5 but none was installed
peerDependencies WARNING puppeteer@22.2.0 › puppeteer-core@22.2.0 › cross-fetch@4.0.0 › node-fetch@^2.6.12 requires a peer of encoding@^0.1.0 but none was installed
peerDependencies WARNING puppeteer@22.2.0 › puppeteer-core@22.2.0 › ws@8.16.0 requires a peer of utf-8-validate@>=5.0.2 but none was installed
Recently updated (since 2024-02-17): 7 packages (detail see file /Users/crazyair/test/puppeteer-install/node_modules/.recently_updates.txt)
✔ All packages installed (118 packages installed from npm registry, used 43s(network 2s), speed 79.45KB/s, json 6(49.14KB), tarball 83.38KB, manifests cache hit 108, etag hit 108 / miss 6)
 npm i --registry=https://registry.npmmirror.com
npm ERR! code 1
npm ERR! path /Users/crazyair/test/puppeteer-install/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c node install.mjs
npm ERR! Error: ERROR: Failed to set up chrome-headless-shell v123.0.6301.2! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
npm ERR!     at file:///Users/crazyair/test/puppeteer-install/node_modules/puppeteer/lib/esm/puppeteer/node/install.js:84:27
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR!     at async Promise.all (index 1)
npm ERR!     at async downloadBrowser (file:///Users/crazyair/test/puppeteer-install/node_modules/puppeteer/lib/esm/puppeteer/node/install.js:90:9) {
npm ERR!   [cause]: Error: connect ECONNREFUSED 0.0.0.0:443
npm ERR!       at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
npm ERR!     errno: -61,
npm ERR!     code: 'ECONNREFUSED',
npm ERR!     syscall: 'connect',
npm ERR!     address: '0.0.0.0',
npm ERR!     port: 443
npm ERR!   }
npm ERR! }

npm ERR! A complete log of this run can be found in: /Users/crazyair/.npm/_logs/2024-02-23T23_01_46_996Z-debug-0.log
crazyair commented 4 months ago

binary会有本地的缓存,所以下载过一次之后就没问题了。应该和 #649 说的是同一个问题,正确的地址应该是https://registry.npmmirror.com/-/binary/chrome-for-testing/

这个不对,我配置这个可以了

PUPPETEER_DOWNLOAD_BASE_URL="https://cdn.npmmirror.com/binaries/chrome-for-testing"

fengmk2 commented 4 months ago

核心问题还是没有同步成功,Error: ERROR: Failed to set up chrome-headless-shell v122.0.6261.57! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.

https://registry.npmmirror.com/binary.html?path=chrome-for-testing/122.0.6261.57/ 现在已经有了,可以成功了。

crazyair commented 4 months ago

https://registry.npmmirror.com/-/binary/chrome-for-testing/ 这个不能用,是因为有个斜杠,需要删除后才能下载

在已经有下载过 puppteer 目录下执行,可以测试这个 base url 是否可用

export PUPPETEER_DOWNLOAD_BASE_URL="https://registry.npmmirror.com/-/binary/chrome-for-testing" 
node node_modules/puppeteer/install.mjs
fengmk2 commented 4 months ago

参考 https://github.com/cnpm/binary-mirror-config/blob/master/package.json#L61C1-L63C1

    "PUPPETEER_DOWNLOAD_HOST": "https://cdn.npmmirror.com/binaries/chrome-for-testing",
    "PUPPETEER_DOWNLOAD_BASE_URL": "https://cdn.npmmirror.com/binaries/chrome-for-testing",