SnowdogApps / vuepress-plugin-pdf-export

Vuepress plugin for exporting as PDF without system wide dependencies suitable for headless environments
MIT License
29 stars 7 forks source link

Error: net::ERR_EMPTY_RESPONSE #9

Closed Red-Asuka closed 3 years ago

Red-Asuka commented 3 years ago

package.json

  "scripts": {
    "dev": "vuepress dev docs",
    "build": "vuepress build docs",
    "pdf": "vuepress build docs && cd docs && vuepress export"
  },

Warning with yarn run pdf:

info Start to generate current site to PDF ...
Error: net::ERR_EMPTY_RESPONSE at http://0.0.0.0:8080/cn/broker/latest/
✨  Done in 8.36s.
Igloczek commented 3 years ago

Hi, you need to set the path while using export method, so in your case, it will be vuepress export docs and run it from the same place as dev and build.

This is all you need to generate PDF from your docs

  "scripts": {
    "dev": "vuepress dev docs",
    "build": "vuepress build docs",
    "pdf": "vuepress export docs"
  },
Red-Asuka commented 3 years ago

it is work, but generate failed package.json

"scripts": {
    "dev": "vuepress dev docs",
    "build": "vuepress build docs",
    "pdf": "vuepress export docs"
  },
  "devDependencies": {
    "@vuepress/plugin-back-to-top": "^1.7.1",
    "@vuepress/plugin-google-analytics": "^1.7.1",
    "@vuepress/plugin-medium-zoom": "^1.7.1",
    "@vuepress/plugin-nprogress": "^1.7.1",
    "node-sass": "4.14.1",
    "sass-loader": "7.3.1",
    "vuepress": "^1.7.1"
  },
  "dependencies": {
    "@snowdog/vuepress-plugin-pdf-export": "^1.1.0",
    "axios": "^0.21.0",
    "bulma": "^0.9.1",
    "vuepress-plugin-export": "^0.2.0"
  }

Warning with yarn run pdf:

➜  frontend git:(feat/pdf) ✗ yarn pdf
yarn run v1.22.4
$ vuepress export docs

wait Extracting site metadata...
tip Apply local theme at /Users/emqx/liyd/docs.emqx.io/frontend/docs/.vuepress/theme...
tip Apply theme local (extends @vuepress/theme-default) ...
tip Apply plugin container (i.e. "vuepress-plugin-container") ...
tip Apply plugin @vuepress/last-updated (i.e. "@vuepress/plugin-last-updated") ...
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
tip Apply plugin smooth-scroll (i.e. "vuepress-plugin-smooth-scroll") ...
tip Apply plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
tip Apply plugin vuepress-plugin-anonymous-08ab35ea ...
tip Apply plugin @vuepress/back-to-top (i.e. "@vuepress/plugin-back-to-top") ...
tip Apply plugin @vuepress/medium-zoom (i.e. "@vuepress/plugin-medium-zoom") ...
tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...
tip Apply plugin @vuepress/google-analytics (i.e. "@vuepress/plugin-google-analytics") ...
tip Apply plugin @snowdog/pdf-export (i.e. "@snowdog/vuepress-plugin-pdf-export") ...

● Client █████████████████████████ building (40%) 72/112 modules 40 active
 node_modules/core-js/internals/shared.js

ℹ 「wds」: Project is running at http://0.0.0.0:8081/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /frontend/docs/.vuepress/public
ℹ 「wds」: 404s will fallback to /index.html
info Start to generate current site to PDF ...
Error: net::ERR_EMPTY_RESPONSE at http://0.0.0.0:8081/cn/broker/latest/api.html
✨  Done in 15.41s.
Igloczek commented 3 years ago

Are you sure that yarn dev command works fine and the file src/cn/broker/latest/api.md does not have some invalid syntax, which means that if you open http://0.0.0.0:8080/cn/broker/latest/api.html the page is rendering correctly?

Also I'd suggest to not run multiple instances of Vuepress at the same time.

In general, it does not look like a plugin problem, but Vuepress issues.

simeld commented 3 years ago

Same error.

It seems that the pdf generation starts before the build is finished (only 40% in progressbar)

Running on nodejs=13.13.0 and yarn=1.22.10

wait Extracting site metadata...
tip Apply theme @vuepress/theme-default ...
tip Apply plugin container (i.e. "vuepress-plugin-container") ...
tip Apply plugin @vuepress/last-updated (i.e. "@vuepress/plugin-last-updated") ...
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
tip Apply plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...
tip Apply plugin smooth-scroll (i.e. "vuepress-plugin-smooth-scroll") ...
tip Apply plugin mathjax (i.e. "vuepress-plugin-mathjax") ...
tip Apply plugin @snowdog/pdf-export (i.e. "@snowdog/vuepress-plugin-pdf-export") ...

* Client █████████████████████████ building (40%) 21/21 modules 0 active

i 「wds」: Project is running at http://0.0.0.0:8080/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from (...)\docs\.vuepress\public
i 「wds」: 404s will fallback to /index.html
info Start to generate current site to PDF ...
Error: net::ERR_ADDRESS_INVALID at http://0.0.0.0:8080/base/ch-1/page-1.html
Done in 5.29s.
Igloczek commented 3 years ago

Could you please prepare a demo repository to reproduce that problems?

itsxallwater commented 3 years ago

The net::ERR_ADDRESS_INVALID at http://0.0.0.0:8080 error is indicative of an error running this on Windows, I think. I ran into the same issue last night, and the original version of this plugin also suffers from the same problem (see https://github.com/ulivz/vuepress-plugin-export/issues/11).

Fortunately I think there's an easy fix, also documented in that issue. To work around it on my Windows box I changed:

https://github.com/SnowdogApps/vuepress-plugin-pdf-export/blob/abf882133dbf8bc1d2fc5842c725f1338020ce01/src/extendCli.js#L34

to:

host: 'localhost'

Then it built and ran great.

@Igloczek kudos on this plugin, btw. The original failed to build the final PDF for me due to the overall size of my docs project (the final java command to run a merge process bombed out). Yours does not suffer from that same issue. I also like the enhancements you made to not print navigation elements--very handy!

Red-Asuka commented 3 years ago

The net::ERR_ADDRESS_INVALID at http://0.0.0.0:8080 error is indicative of an error running this on Windows, I think. I ran into the same issue last night, and the original version of this plugin also suffers from the same problem (see ulivz/vuepress-plugin-export#11).

Fortunately I think there's an easy fix, also documented in that issue. To work around it on my Windows box I changed:

https://github.com/SnowdogApps/vuepress-plugin-pdf-export/blob/abf882133dbf8bc1d2fc5842c725f1338020ce01/src/extendCli.js#L34

to:

host: 'localhost'

Then it built and ran great.

@Igloczek kudos on this plugin, btw. The original failed to build the final PDF for me due to the overall size of my docs project (the final java command to run a merge process bombed out). Yours does not suffer from that same issue. I also like the enhancements you made to not print navigation elements--very handy!

thanks,I changed my config.js, it generat pdf success.

module.exports = {
  host: 'localhost',
}