node.js - 无法让 Puppeteer 工作和安装

标签 node.js windows ubuntu installation puppeteer

可能是一个新手问题,但我真的很难让 Puppeteer 工作。我可能在下载的某个地方搞砸了,但我就是想不通。
我的 puppeteer 版本是 5.1.0
Node 是 v14.5.0
在 Ubuntu 18.04 上运行,但也无法在 Windows 命令行上运行
Windows 10
这是我的 package.json:

    {
  "name": "test_puppeteer",
  "version": "1.0.0",
  "description": "",
  "main": "test.js",
  "dependencies": {
    "puppeteer": "^5.1.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
我尝试运行此测试,它适用于 example.com,但没有其他网站并且它没有正确关闭
这是我的基本截图测试:
var puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
      args: ['--no-sandbox', '--disable-setuid-sandbox']})
  const page = await browser.newPage();
  await page.goto('https://www.example.com');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();
如果我运行它,我会创建 example.png,但没有其他反馈,如果我将站点更改为其他任何内容,我会得到 (node:28737) UnhandledPromiseRejectionWarning: TimeoutError: Navigation timeout of 30000 ms exceeded

最佳答案

我是个傻瓜,答案在于我自己电脑的权限困惑。从长远来看,这可能不是很好,但是当我在桌面上的文件夹中运行 puppeteer 时,我没有任何问题,忽略这个!

关于node.js - 无法让 Puppeteer 工作和安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62903003/

相关文章:

node.js - 如何使用 Azure DevOps 管道来运行 LUIS 调度模型的刷新

ubuntu - Redis 升级后无法启动

python - 如何让 Python3.7 指向另一个 Python 解释器

node.js - heroku实例错误: unable to verify the first certificate上的 Node

node.js - MS Bot 框架 v4 - 无法将 QnA 生成器添加到机器人 - 主机名加密值不是有效格式

unit-testing - 测试 MongooseJs 验证

c++ - Visual Studio 2013 C++ 中的位图透明度

windows - 如何使用 AutoIt 在 Windows 中打开 "Run Window"?

windows - 是否可以在 Windows 上配置 JVM 以不加载 msvcr100.dll?

linux - 有没有办法捕获请求日志文件中没有响应的行?