kohheepeace / mr-pdf

Generate PDF for document website.
https://www.npmjs.com/package/mr-pdf
MIT License
125 stars 41 forks source link

Unexpected token '.' #25

Open captv89 opened 3 years ago

captv89 commented 3 years ago

OS: Windows 10

Running the example command for Docusaurus v2 fails with the message Unexpected token '.'

Command:

npx mr-pdf --initialDocURLs="https://docusaurus.io/docs/" --contentSelector="article" --paginationSelector=".pagination-nav__item--next > a" --excludeSelectors=".margin-vert--xl a" --coverImage="https://docusaurus.io/img/docusaurus.png" --coverTitle="Docusaurus v2"

Screenshot: image

pankaj-pant commented 3 years ago

I was having this issue on a Mac as well. For me the issue was happening due to the version of node that I was using. On node v12.22.1 this error was being generated. For work I need to switch between different version of node regularly, so I used nvm to change the node version to v14.17.0, and the pdf generated successfully. Hope this helps.

BjarkeNL commented 1 year ago

Are you using NVM for windows? I experienced something similar with NPX and with the same error message (when installing docusaurus with npx).

What worked for me was to upgrade "NVM for windows" to the latest version. (https://github.com/coreybutler/nvm-windows)

Afterwards, you also have to reinstall the node version(s) causing problems, see: https://github.com/npm/cli/issues/4234#issuecomment-1275612483

kohheepeace commented 1 year ago

Close the issue according to the @pankaj-pant solution. Thanks!

kohheepeace commented 1 year ago

Re-open this issue. Benefits when considering Dockerize.