我正在尝试构建一个简单的网络爬虫,而我要做的第一件事是安装puppeteer库。所以我运行命令(我在最新的Linux Mint上):
sudo npm init -y
和sudo npm i puppeteer
,但出现以下错误:
▌ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine puppeteer@3.0.2: wanted: {"node":">=10.18.1"} (current: {"node":"8.10.0","npm":"3.5.2"})
loadDep:ws → request ▄ ╢███████████████████████████░░░░░░░░░░░░░░░░╟
> puppeteer@3.0.2 install /home/USER/Documents/anna/file/node_modules/puppeteer
> node install.js
(node:11081) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function
at promisify (internal/util.js:209:11)
at Object.<anonymous> (/home/USER/Documents/anna/file/node_modules/extract-zip/index.js:11:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/USER/Documents/anna/file/node_modules/puppeteer/lib/BrowserFetcher.js:25:17)
(node:11081) 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(). (rejection id: 1)
(node:11081) [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.
file@1.0.0 /home/USER/Documents/anna/file
└── puppeteer@3.0.2 extraneous
npm WARN ws@7.2.5 requires a peer of bufferutil@^4.0.1 but none was installed.
npm WARN ws@7.2.5 requires a peer of utf-8-validate@^5.0.2 but none was installed.
npm WARN file@1.0.0 No description
npm WARN file@1.0.0 No repository field.
有什么想法为什么会发生?
答案 0 :(得分:0)
您似乎需要升级Node.js版本。输出中的警告:
WARN engine puppeteer@3.0.2: wanted: {"node":">=10.18.1"} (current: {"node":"8.10.0","npm":"3.5.2"})
表示您正在运行Node 8.10,Puppeteer希望Node> = 10.18.1。