问题
I am trying to build a simple web scraper and the first thing I have to do is install the puppeteer library. So I run the commands (I am on the latest linux Mint):
sudo npm init -y
and sudo npm i puppeteer
but I get these errors:
▌ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
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.
Any ideas why this is happening?
回答1:
It looks like you need to upgrade your Node.js version. The warning in the output:
WARN engine puppeteer@3.0.2: wanted: {"node":">=10.18.1"} (current: {"node":"8.10.0","npm":"3.5.2"})
indicates you're running Node 8.10 and Puppeteer expects Node >= 10.18.1.
来源:https://stackoverflow.com/questions/61524375/i-am-having-toruble-installing-the-puppeteer-library