搞node爬蟲--puppeteer--記一次大坑


解決辦法:升級node,然后重新下載puppeteer插件

設置淘寶鏡像下載
npm config set puppeteer_download_host=https://npm.taobao.org/mirrors

npm install puppeteer

 

 

問題:報錯

(node:828) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
[0104/213745.484:ERROR:main_dll_loader_win.cc(109)] Failed to load Chrome DLL from E:\node學習\node_modules\puppeteer\.local-chromium\win64-818858\chrome-win\chrome.dll: �Ҳ���ָ����ģ�顣 (0x7E)
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (E:\node學習\node_modules\puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:193:20)
    at ChildProcess.<anonymous> (E:\node學習\node_modules\puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:184:79)
    at ChildProcess.emit (events.js:327:22)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:828) 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:828) [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.

 解決:

官方:

Chrome is downloaded but fails to launch on Node.js 14

If you get an error that looks like this when trying to launch Chromium:

(node:15505) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
spawn /Users/.../node_modules/puppeteer/.local-chromium/mac-756035/chrome-mac/Chromium.app/Contents/MacOS/Chromium ENOENT

This means that the browser was downloaded but failed to be extracted correctly. The most common cause is a bug in Node.js v14.0.0 which broke extract-zip, the module Puppeteer uses to extract browser downloads into the right place. The bug was fixed in Node.js v14.1.0, so please make sure you're running that version or higher. Alternatively, if you cannot upgrade, you could downgrade to Node.js v12, but we recommend upgrading when possible.

 翻譯:

Chrome已下載,但無法在上啟動節點.js14


如果在嘗試啟動Chromium時出現如下錯誤:


(節點:15505)未處理的PromisejectionWarning:錯誤:無法啟動瀏覽器進程!

spawn/Users/../node\u modules/puppeteer/.local chromium/mac-756035/chrome mac/Chromium.app/Contents/MacOS/Chromium文件依諾特


這意味着瀏覽器已下載,但未能正確提取。最常見的原因是節點.js其中v14.0.0打破了解壓zip,模組puppeter用來解壓瀏覽器下載到正確的地方。qietingqi已修復節點.jsv14.1.0,所以請確保您運行的是該版本或更高版本。或者,如果您不能升級,您可以降級到節點.jsv12,但我們建議在可能的情況下升級。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM