ggrossetie / asciidoctor-web-pdf

Convert AsciiDoc documents to PDF using web technologies
https://asciidoctor.org
MIT License
448 stars 92 forks source link

What are the OS requirements? #97

Closed rdmueller closed 4 years ago

rdmueller commented 4 years ago

just tried to install asciidoctor-pdf.js on windows and had some problems. So, here my quick question - has someone already tried to get it up and running on powershell or WSL?

Maybe it is also just because I am not used to node / npm, so I am missing some requirements.

I already figured out that I need to install

any ideas? thanx!

ggrossetie commented 4 years ago

Hello @rdmueller

asciidoctor core (npm i -g asciidoctor core)

The command is:

npm i -g asciidoctor asciidoctor-pdf

core needs "node-waf" which I can't find at the moment (seems to be deprecared and replaced by node-gyp, but installing this doesn't help)

I think you are trying to install the package core: https://www.npmjs.com/package/core which has nothing to do with Asciidoctor. You should remove it because this package might be harmful, it has:

Anyway, you should follow the steps described here: https://github.com/Mogztter/asciidoctor-pdf.js#install

rdmueller commented 4 years ago

thanx for the quick reply.

I was trying to install vi the command from the readme. I got the following warning

npm WARN asciidoctor-pdf@1.0.0-alpha.3 requires a peer of @asciidoctor/core@^2.0.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN @asciidoctor/cli@3.0.1 requires a peer of @asciidoctor/core@^2.0.0-rc.1 but none is installed. You must install peer dependencies yourself.

that's why I tried to install asciidoctor core.

It also seems that I didn't correctly isntall node.js, because I need sudo. And even with sudo I still get the following error message running on WSL, Ubunut:

rdmueller:home/rdmueller$ sudo npm i -g asciidoctor asciidoctor-pdf
/usr/local/bin/asciidoctorjs -> /usr/local/lib/node_modules/asciidoctor/bin/asciidoctor
/usr/local/bin/asciidoctor -> /usr/local/lib/node_modules/asciidoctor/bin/asciidoctor
/usr/local/bin/asciidoctor-pdf -> /usr/local/lib/node_modules/asciidoctor-pdf/bin/asciidoctor-pdf

> puppeteer@1.15.0 install /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/puppeteer
> node install.js

ERROR: Failed to download Chromium r650583! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/asciidoctor-pdf/node_modules/puppeteer/.local-chromium'
  -- ASYNC --
    at BrowserFetcher.<anonymous> (/usr/local/lib/node_modules/asciidoctor-pdf/node_modules/puppeteer/lib/helper.js:110:27)
    at Object.<anonymous> (/usr/local/lib/node_modules/asciidoctor-pdf/node_modules/puppeteer/install.js:64:16)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
    at internal/main/run_main_module.js:17:11 {
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/usr/local/lib/node_modules/asciidoctor-pdf/node_modules/puppeteer/.local-chromium'
}
npm WARN asciidoctor-pdf@1.0.0-alpha.3 requires a peer of @asciidoctor/core@^2.0.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN @asciidoctor/cli@3.0.1 requires a peer of @asciidoctor/core@^2.0.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/asciidoctor-pdf/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
ahus1 commented 4 years ago

@rdmueller @Mogztter - instead of installing asciidoctor-pdf globally, I chose to add a small package.json to the project like this:

{
  "name": "example",
  "version": "1.0.0",
  "dependencies": {
    "asciidoctor": "^2.0.3",
    "asciidoctor-pdf": "^1.0.0-alpha.3"
  },
  "scripts": {
    "handout_01": "node_modules/.bin/asciidoctor-pdf handout_01.adoc"
  }
}

Then I was able to create the PDF using

yarn install
yarn handout_01

Tested on Windows, but should work on other OS as well. All modules end up in a node_modules folder local to the project.

If you fancy npm over yarn the following would work as well

npm install
npm run handout_01

Benefits of this approach as I see them:

Please let me know what you think.

ggrossetie commented 4 years ago

I was trying to install vi the command from the readme. I got the following warning

You shouldn't get this warning because @asciidoctor/core is "included" in the asciidoctor package. So the following command will effectively install @asciidoctor/core:

npm i -g asciidoctor

But even if the package is missing (for unknown reasons) you should install @asciidoctor/core not asciidoctor core.

It also seems that I didn't correctly isntall node.js, because I need sudo. And even with sudo I still get the following error message running on WSL, Ubunut:

To be honest, I've never tried WSL but you shouldn't use sudo.

As mentioned by @ahus1 you could install the packages locally by removing the -g flag or you could use nvm (https://github.com/nvm-sh/nvm#important-notes) to install the packages on your user space (ie. /home/user/.nvm) not on the system space (/usr/local/lib).

ggrossetie commented 4 years ago

You can even remove node_modules/.bin/ from the command:

{
  "name": "example",
  "version": "1.0.0",
  "dependencies": {
    "asciidoctor": "^2.0.3",
    "asciidoctor-pdf": "^1.0.0-alpha.3"
  },
  "scripts": {
    "handout_01": "asciidoctor-pdf handout_01.adoc"
  }
}

npm will be able to resolve it.

And if you want to quickly test Asciidoctor PDF, you can use npx;

$ npx --version
6.12.0
$ npm --version
6.12.0
$ node --version
v12.13.0
$ npx asciidoctor-pdf test.adoc
rdmueller commented 4 years ago

thanx! The yarn-approach worked for me on WSL! I will now check out the other hints to see what went wrong.

ggrossetie commented 4 years ago

We can certainly improve the documentation so feel free to suggest improvements.

I recommended global installation because then the asciidoctor-pdf is available "everywhere" but we should probably mention other installation setup: