Puppeteer浏览器下载失败。

huangapple go评论86阅读模式
英文:

Puppeteer browser download failed

问题

Here is the translated portion:

所以基本上我刚刚开始使用puppeteer.js。我的系统似乎无法正确地进行npm安装这个库。以下是我所做的步骤:

  1. 创建新目录
  2. 在bash中导航到该目录
  3. npm init -y
  4. npm install puppeteer

在执行这些步骤后,我收到了如下错误消息:

$ npm i puppeteer

> puppeteer@20.7.1 postinstall C:\Users\neilj\Desktop\puppeteer2\node_modules\puppeteer
> node install.js

Browser download failed C:\Users\neilj\Desktop\puppeteer2\node_modules\@puppeteer\browsers\lib\cjs\launch.js:48
    options.platform ??= (0, detectPlatform_js_1.detectBrowserPlatform)();
                     ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:988:16)
    at Module._compile (internal/modules/cjs/loader.js:1036:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (C:\Users\neilj\Desktop\puppeteer2\node_modules\@puppeteer\browsers\lib\cjs\main.js:19:19)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for puppeteer@20.7.1: wanted: {"node":">=16.3.0"} (current: {"node":"14.17.5","npm":"6.14.14"})
npm WARN notsup Not compatible with your version of node/npm: puppeteer@20.7.1
npm WARN notsup Unsupported engine for puppeteer-core@20.7.1: wanted: {"node":">=16.3.0"} (current: {"node":"14.17.5","npm":"6.14.14"})
npm WARN notsup Not compatible with your version of node/npm: puppeteer-core@20.7.1
npm WARN notsup Unsupported engine for @puppeteer/browsers@1.4.1: wanted: {"node":">=16.3.0"} (current: {"node":"14.17.5","npm":"6.14.14"})npm WARN notsup Not compatible with your version of node/npm: @puppeteer/browsers@1.4.1
npm WARN puppeteer2@1.0.0 No description
npm WARN puppeteer2@1.0.0 No repository field.

我想知道是否有其他人遇到过这个错误,因为我似乎找不到其他帖子中出现这个特定问题的情况。

我基本上只是想安装这个代码,以便首先能够使用它。如果有人有任何见解,我打算获取一些。谢谢。

英文:

So basically I'm just starting out with puppeteer.js. My systems seems unable to npm install the library correctly. Here is what I did:

  1. Make new directory
  2. Navigate to said directory in bash
  3. npm init -y
  4. npm install puppeteer

After doing those steps I get a error message exactly like this

$ npm i puppeteer

&gt; puppeteer@20.7.1 postinstall C:\Users\neilj\Desktop\puppeteer2\node_modules\puppeteer
&gt; node install.js

Browser download failed C:\Users\neilj\Desktop\puppeteer2\node_modules\@puppeteer\browsers\lib\cjs\launch.js:48
    options.platform ??= (0, detectPlatform_js_1.detectBrowserPlatform)();
                     ^^^

SyntaxError: Unexpected token &#39;??=&#39;
    at wrapSafe (internal/modules/cjs/loader.js:988:16)
    at Module._compile (internal/modules/cjs/loader.js:1036:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.&lt;anonymous&gt; (C:\Users\neilj\Desktop\puppeteer2\node_modules\@puppeteer\browsers\lib\cjs\main.js:19:19)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for puppeteer@20.7.1: wanted: {&quot;node&quot;:&quot;&gt;=16.3.0&quot;} (current: {&quot;node&quot;:&quot;14.17.5&quot;,&quot;npm&quot;:&quot;6.14.14&quot;})
npm WARN notsup Not compatible with your version of node/npm: puppeteer@20.7.1
npm WARN notsup Unsupported engine for puppeteer-core@20.7.1: wanted: {&quot;node&quot;:&quot;&gt;=16.3.0&quot;} (current: {&quot;node&quot;:&quot;14.17.5&quot;,&quot;npm&quot;:&quot;6.14.14&quot;})    
npm WARN notsup Not compatible with your version of node/npm: puppeteer-core@20.7.1
npm WARN notsup Unsupported engine for @puppeteer/browsers@1.4.1: wanted: {&quot;node&quot;:&quot;&gt;=16.3.0&quot;} (current: {&quot;node&quot;:&quot;14.17.5&quot;,&quot;npm&quot;:&quot;6.14.14&quot;})npm WARN notsup Not compatible with your version of node/npm: @puppeteer/browsers@1.4.1
npm WARN puppeteer2@1.0.0 No description
npm WARN puppeteer2@1.0.0 No repository field.

I was wondering if anyone else had come across this error since I cannot seem to find another thread that had this particular issue

I'm basically just trying to get this code installed so I can work with it in the first place. Im intending to get some insight if anyone has any. Thanks

答案1

得分: 3

这发生在我身上是因为我使用了Node v14和puppeteer v20。你需要Node v15来运行puppeteer v20,或者puppeteer < v20与Node v14。

> 注意: Node v14支持??,但不支持??=,后者需要Node v15支持(来源

英文:

This happened to me because I was using Node v14 and puppeteer v20. You'll need Node v15 for puppeteer v20 or puppeteer < v20 with Node v14.

> Note: Node v14 supports ?? but not ??= which is supported after Node v15 (source)

huangapple
  • 本文由 发表于 2023年6月15日 10:21:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76478677.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定