英文:
Puppeteer browser download failed
问题
Here is the translated portion:
所以基本上我刚刚开始使用puppeteer.js。我的系统似乎无法正确地进行npm安装这个库。以下是我所做的步骤:
- 创建新目录
- 在bash中导航到该目录
npm init -y
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:
- Make new directory
- Navigate to said directory in bash
npm init -y
npm install puppeteer
After doing those steps I get a error message exactly like this
$ 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.
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论