該賞金到期in 4天。此問題的答案有資格獲得 200聲望獎勵。 Sophivorus想引起更多關注這個問題:
歡迎任何關于可能出現問題或如何找出問題的想法。
當我嘗試使用推薦的方式安裝 PagedJS時,npm install -g pagedjs-cli pagedjs我得到:
npm WARN deprecated @babel/polyfill@7.12.1: ?? This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when neded). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 enginewhims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path /root/.nvm/versions/node/v14.17.5/lib/node_modules/pagedjs-cli/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! internal/modules/cjs/loader.js:905
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module '/root/.nvm/versions/node/v14.17.5/lib/node_modules/pagedjs-cli/node_modules/puppeteer/install.js'
npm ERR! at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
npm ERR! at Function.Module._load (internal/modules/cjs/loader.js:746:27)
npm ERR! at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
npm ERR! at internal/main/run_main_module.js:17:47 {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: []
npm ERR! }
如果我運行,npm install -g puppeteer我會得到完全相同的錯誤(減去警告)。
我嘗試了本地安裝,npm install pagedjs-cli pagedjs一切順利(運行時npm ls我得到:
├── pagedjs-cli@0.1.6
├── pagedjs@0.2.0
└── puppeteer@10.4.0
這似乎表明相關軟體包已在本地成功安裝)。但是當我嘗試運行 PagedJS 時,npx pagedjs-cli example.html -o result.pdf我得到:
Loading: example.htmlError: Failed to launch the browser process!
/home/sophivorus/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome: error while loading shared libraries: libatk-bridge-2.0.so.0: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/home/sophivorus/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
at Interface.<anonymous> (/home/sophivorus/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:187:68)
at Interface.emit (events.js:412:35)
at Interface.close (readline.js:530:8)
at Socket.onend (readline.js:254:10)
at Socket.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1334:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
I then tried installing the missing library with yum install libatk-bridge-2.0.so.0 and everything went fine (when I run ldconfig -p | grep libatk-bridge-2.0.so.0 I get:
libatk-bridge-2.0.so.0 (libc6) => /lib/libatk-bridge-2.0.so.0
which seems to indicate that the library was successfully installed). However when I retry npx pagedjs-cli example.html -o result.pdf I get the exact same error. If I avoid npx with /home/sophivorus/node_modules/.bin/pagedjs-cli example.html -o result.pdf I get the same error.
I'm on CentOS 7 and running the latest node and npm:
node -v
v17.0.1
npm -v
8.1.0
I also tried with the latest LTS version. Thanks for any help!
uj5u.com熱心網友回復:
您嘗試使用的庫 (pagedjs) 似乎非常不完整,基于其他庫的過時和棄用版本,并且僅由一名開發人員維護。它總共只有大約 100 個提交。我建議切換到jsPDF。它有超過 4000 個分叉,我對提交完全保持沉默。它得到積極維護并且非常受歡迎。盡管如此,這只是我發現的第一個。也許你可以找到更好的圖書館......
這個問題也可能對你有幫助: Generate pdf from HTML in div using Javascript
uj5u.com熱心網友回復:
包有另一個名字...
repoquery --list at-spi2-atk.x86_64
lib并且lib64不是一回事:
ldd /usr/lib64/libatk-bridge-2.0.so.0.0.0ldd /lib/libatk-bridge-2.0.so.0
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/335642.html
標籤:node.js npm puppeteer npx pagedjs
上一篇:在shell腳本中呼叫鏈碼函式
