搞node爬虫--puppeteer--记一次大坑

解决办法:升级node,然后重新下载puppeteer插件

设置淘宝镜像下载
npm config set puppeteer_download_host=https://npm.taobao.org/mirrors

npm install puppeteer

 

 

问题:报错

1
2
3
4
5
6
7
8
9
10
11
12
13
(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.

 解决:

官方:

1
2
3
4
5
6
7
8
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.

 翻译:

1
2
3
4
5
6
7
8
9
10
11
12
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,但我们建议在可能的情况下升级。

 

posted @   小白咚  阅读(3430)  评论(1编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示