- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经开始使用 Puppeteer,但出于某种原因我无法让它在我的盒子上工作。这个错误似乎是一个常见问题( SO1 , SO2 )但所有的解决方案都没有为我解决这个错误。我已经使用干净的 Node 包对其进行了测试(参见复制),并且我已经从官方 Puppeteer“入门”网页中获取了示例。
我该如何解决这个错误?
/tmp/so_example » uname -a
Linux tom.arch 5.15.2-arch1-1 #1 SMP PREEMPT Fri, 12 Nov 2021 19:22:10 +0000 x86_64 GNU/Linux
/tmp/so_example » node --version
v17.1.0
/tmp/so_example » npm list
so_example@1.0.0 /tmp/so_example
└── puppeteer@11.0.0
/tmp/so_example » cat /proc/meminfo
MemTotal: 32492764 kB
MemFree: 600032 kB
MemAvailable: 24446556 kB
Buffers: 7149964 kB
Cached: 9549048 kB
SwapCached: 0 kB
Active: 9843552 kB
Inactive: 10980476 kB
Active(anon): 462692 kB
Inactive(anon): 5481100 kB
Active(file): 9380860 kB
Inactive(file): 5499376 kB
Unevictable: 723108 kB
Mlocked: 17336 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 4 kB
Writeback: 0 kB
AnonPages: 4848276 kB
Mapped: 625156 kB
Shmem: 1816292 kB
KReclaimable: 9438608 kB
Slab: 10007568 kB
SReclaimable: 9438608 kB
SUnreclaim: 568960 kB
KernelStack: 26240 kB
PageTables: 63012 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 16246380 kB
Committed_AS: 16256172 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 103964 kB
VmallocChunk: 0 kB
Percpu: 14592 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 5072608 kB
DirectMap2M: 20758528 kB
DirectMap1G: 7340032 kB
/tmp/so_example » lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
CPU family: 6
Model: 165
Thread(s) per core: 2
Core(s) per socket: 8
Socket(s): 1
Stepping: 2
CPU max MHz: 5100.0000
CPU min MHz: 800.0000
BogoMIPS: 4601.60
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology
nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnow
prefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust sgx bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt inte
l_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp pku ospke sgx_lc md_clear flush_l1d arch_capabilities
Virtualization features:
Virtualization: VT-x
Caches (sum of all):
L1d: 256 KiB (8 instances)
L1i: 256 KiB (8 instances)
L2: 2 MiB (8 instances)
L3: 16 MiB (1 instance)
NUMA:
NUMA node(s): 1
NUMA node0 CPU(s): 0-15
Vulnerabilities:
Itlb multihit: KVM: Mitigation: VMX disabled
L1tf: Not affected
Mds: Not affected
Meltdown: Not affected
Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling
Srbds: Not affected
Tsx async abort: Not affected
/tmp/so_example » npm init -y
Wrote to /tmp/so_example/package.json:
{
"name": "so_example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
/tmp/so_example » npm i puppeteer
added 57 packages, and audited 58 packages in 11s
8 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
/tmp/so_example » npm list
so_example@1.0.0 /tmp/so_example
└── puppeteer@11.0.0
/tmp/so_example » echo "const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://google.com');
await browser.close();
})();" > example.js
/tmp/so_example » nvm use 17
Now using node v17.1.0 (npm v8.1.2)
/tmp/so_example » node example.js
/tmp/so_example/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:226
error: new Errors_js_1.ProtocolError(),
^
ProtocolError: Protocol error (Page.navigate): Target closed.
at /tmp/so_example/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:226:24
at new Promise (<anonymous>)
at CDPSession.send (/tmp/so_example/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:222:16)
at navigate (/tmp/so_example/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:148:47)
at FrameManager.navigateFrame (/tmp/so_example/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:131:13)
at Frame.goto (/tmp/so_example/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:500:41)
at Page.goto (/tmp/so_example/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1167:53)
at /tmp/so_example/example.js:6:14
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
originalMessage: undefined
}
Node.js v17.1.0
我在以下版本中遇到同样的错误:
/tmp/so_example » nvm use 16
Now using node v16.13.0 (npm v8.1.0)
/tmp/so_example » nvm use 15
Now using node v15.14.0 (npm v7.7.6)
/tmp/so_example » nvm use 14
Now using node v14.18.1 (npm v6.14.15)
我还在 this guide 之后尝试在 Docker 上进行相同的安装.使用此设置,它似乎可以工作。这表明这是一个与操作系统/程序包相关的问题。
/tmp/so_example » echo "const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: true,
args: [
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-setuid-sandbox',
'--no-sandbox',
]
});
const page = await browser.newPage();
await page.goto('https://google.com');
await browser.close();
console.log('If I made it here there is no error');
})();" > example.js
/tmp/so_example » echo "FROM node:17-slim
# Chrome dependencies
RUN apt-get update && apt-get -f install -y \\
fonts-liberation \\
gconf-service \\
#libappindicator1 \\
libasound2 \\
libatk1.0-0 \\
libcairo2 \\
libcups2 \\
libfontconfig1 \\
libgbm-dev \\
libgdk-pixbuf2.0-0 \\
libgtk-3-0 \\
libicu-dev \\
libjpeg-dev \\
libnspr4 \\
libnss3 \\
libpango-1.0-0 \\
libpangocairo-1.0-0 \\
libpng-dev \\
libx11-6 \\
libx11-xcb1 \\
libxcb1 \\
libxcomposite1 \\
libxcursor1 \\
libxdamage1 \\
libxext6 \\
libxfixes3 \\
libxi6 \\
libxrandr2 \\
libxrender1 \\
libxss1 \\
libxtst6 \\
xdg-utils
COPY . ./
RUN npm install
# Make browser executable for puppeteer
RUN chmod -R o+rwx node_modules/puppeteer/.local-chromium
CMD [\"node\", \"example.js\"]" > Dockerfile
/tmp/so_example » docker run -it $(docker build -q .)
If I made it here there is no error
正如对这个问题的评论,添加
executablePath: 'path/to/local/chromium'
puppeteer 配置使复制在系统上运行。我仍然想知道为什么用 puppeteer 打包的 chromium 不起作用,因为在多开发环境中使用本地可执行文件的静态路径是一种非常糟糕的做法。
最佳答案
令人惊讶的是,在更新到 Puppeteer 版本 12.0.0 之后,一切似乎都能正常工作。到目前为止,我不知道是什么导致了这个问题,又是什么让它消失了,但它现在有效了。
编辑:可以找到变更日志 here ,大概是 Chromium 97.0.4692.0 的更新解决了这个问题。
关于node.js - Puppeteer 无法在 Arch Linux 上运行 NodeJS 17,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70032857/
我的 React 项目需要更新 nodejs。那么我如何将我的 Node js 重新安装到 Ubuntu 16.04 中的最新版本。 我当前的 Node 版本是 node -v v6.0.0 我当前的
我正在寻找逐步调试 NodeJS 服务器代码的有效方法。目前我使用了几十个console.log(),这非常困难。完美的工具可以让我检查堆栈中每个变量的值并逐行跟踪我的程序。首选操作系统 = MacO
我的网站上有以下两个文件: firebase.js gridsome-server.js firebase.js 是一个“常规”javascript 文件,包含以下内容: import firebas
我有一个nodejs应用程序从文件夹A执行,二进制X也在文件夹A中执行(使用子进程exec)。二进制 X 在文件夹 A 中生成输出文件 O,因此始终从调用位置开始。 我需要nodejs应用程序来在仲裁
我有以下nodeJS服务器,它似乎工作正常。我想编写一个客户端,从服务器接收消息并根据消息调用一些 JS。 涉及的步骤是: 用户访问网址http://server.xyz.com:8080/pa no
我想从 Node 服务器进行其余 api 调用。我目前脑子里有请求模块。 您是否会建议用于 Nodejs 中生产实践的 REST 调用(get/post)的任何其他最佳模块? 问候,公羊 最佳答案 R
我正在尝试像这样使用 mainModule: const { mainModule } = require('process'); module.exports = path.dirname(main
我现在对那些版本号真的很困惑。我正在计划一个新项目,想知道这两个版本之间有什么区别。这两个版本之间似乎有很大的跳跃,但现在我找不到区别。 使用 4.1 版安全吗? 感谢您的帮助! 最佳答案 跳转到 v
我试图找到我的问题的解决方案,但找不到,并且正在寻找一些“最佳实践示例”。我有一个 nodejs express 应用程序,我的函数在文件中拆分。例如我有这个 Controller (oktacont
这看起来像是一个非常简单的问题,但作为一个 JS 初学者,我想知道是否可以在 webextension 中使用 NodeJS 模块(例如我想使用这个:https://github.com/yaronn
我有一个文件。a.js class A{ constructor(name){ this.name = name; } displayName(){ conso
我想做的是这样的: node x.js | node y.js 文件 x.js 只是打印一个字符串: console.log("hi"); 文件 y.js 旨在通过 process.stdin 获取字
对于这个新的nodejs debugger I am working on我想对显示的源代码行进行着色。有什么关于 npm 使用的建议吗? 有很多语法荧光笔,但使这种情况有点不同的是 输出是到终端;它
有没有什么方法可以从 ejs View 中引用包含在 node_modules 文件夹中的 Nodejs 库? 我正在使用 expressjs 并且我的客户端库由 /public 文件夹提供,如下所示
我是 NodeJS 的新手,我正在尝试根据 NodeJS 站点上的指南在 NodeJS 中创建一个服务器。我已经在我的电脑上安装了 NodeJS 并使用以下代码制作了 app.js 文件。 const
我有一个 nodejs-express 服务器 (1) 与 mongodb 通信,还有一个 web 服务器 (2) 在 nodejs-express 和 Angularjs 中。我正在尝试发出 pos
我一直在解决(firebase 和 nodejs)问题,这是该问题的第四部分,如何在登录到 server.js 后传递数据 我已经尝试过this但未能使其正常工作。 基本上,我正在尝试将用户idTok
每次页面刷新时,NodeJS 都会在套接字上多次写入数据。当我刷新页面时,nodejs 服务器写入套接字的计数增加,在多个页面刷新时,写入计数固定为 3。 请检查控制台输出是否有此奇怪的响应。请提出同
我在尝试更新文件夹并再次部署其内容时遇到问题。我必须使用 NodeJS 并已获得端口 8080 来使用。我尝试创建一个 php 脚本(update.php): 现在我想启动NodeJS脚本进行更新,
我不明白java多线程系统和Nodejs多线程系统在性能和资源共享方面的区别。由于 NodeJS 为您的程序使用事件循环单线程,但在幕后,它将任务分配给不同的线程,如文件读取或数据库查询。所以它使用多
我是一名优秀的程序员,十分优秀!