Support execution with npx
Situation
When pagedjs-cli is not installed globally and executed using npx, pagedjs-cli throws an error and loads the html file eternally. It seems to expect a pagedjs
installation in parallel to pagedjs-cli
: ...\npm-cache\_npx\34232\node_modules\pagedjs\dist\paged.polyfill.js
Expected behavior
pagedjs-cli can be run using npx. It does not need to be installed globally on a computer. pagedjs-cli
should use pagedjs
from its own modules, something like: ...\npm-cache\_npx\34232\node_modules\pagedjs-cli\node_modules\pagedjs\dist\paged.polyfill.js
Reproduction
# Remove pagedjs-cli from npm
npm uninstall pagedjs-cli -g
# ... or if it was installed with yarn:
yarn global remove pagedjs-cli
npx pagedjs-cli .\print.html -o .\print.pdf
Error details
PS> npx pagedjs-cli .\print.html -o .\print.pdf
Downloading Chromium r722234 - 134.7 Mb [====================] 100% 0.0s
- Loading: .\print.html(node:34232) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\Users\raffel\AppData\Roaming\npm-cache\_npx\34232\node_modules\pagedjs\dist\paged.polyfill.js'
-- ASYNC --
at Frame.<anonymous> (C:\Users\raffel\AppData\Roaming\npm-cache\_npx\34232\node_modules\pagedjs-cli\node_modules\puppeteer\lib\helper.js:111:15)
at Page.addScriptTag (C:\Users\raffel\AppData\Roaming\npm-cache\_npx\34232\node_modules\pagedjs-cli\node_modules\puppeteer\lib\Page.js:421:29)
at Page.<anonymous> (C:\Users\raffel\AppData\Roaming\npm-cache\_npx\34232\node_modules\pagedjs-cli\node_modules\puppeteer\lib\helper.js:112:23)
at Printer.render (C:\Users\raffel\AppData\Roaming\npm-cache\_npx\34232\node_modules\pagedjs-cli\src\printer.js:98:16)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Printer.pdf (C:\Users\raffel\AppData\Roaming\npm-cache\_npx\34232\node_modules\pagedjs-cli\src\printer.js:226:16)
at async C:\Users\raffel\AppData\Roaming\npm-cache\_npx\34232\node_modules\pagedjs-cli\bin\paged:137:14
(Use `node --trace-warnings ...` to show where the warning was created)
(node:34232) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:34232) [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.
| Loading: .\print.html