Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors prevent pdf generation #602

Open
AaronLain opened this issue Feb 18, 2021 · 1 comment
Open

Errors prevent pdf generation #602

AaronLain opened this issue Feb 18, 2021 · 1 comment

Comments

@AaronLain
Copy link

Just wanted to leave this here in case anyone else is having this problem. I came across this error when attempting to turn this book into a pdf. When I ran npm run setup I received this error:

/usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:278
      if (cb) cb.apply(this, arguments)
                 ^

TypeError: cb.apply is not a function

I went to the specified file and found the problematic function.

function statFix (orig) {
  if (!orig) return orig
  // Older versions of Node erroneously returned signed integers for
  // uid + gid.
  return function (target, cb) {
    return orig.call(fs, target, function (er, stats) {
      if (!stats) return cb.apply(this, arguments)
      if (stats.uid < 0) stats.uid += 0x100000000
      if (stats.gid < 0) stats.gid += 0x100000000
      if (cb) cb.apply(this, arguments)
    })
  }
}

What it does, as far as I can tell, is manage some type quirks with older versions of node. In my file, it was called three times up above on lines 62-64.

fs.stat = statFix(fs.stat)
fs.fstat = statFix(fs.fstat)
fs.lstat = statFix(fs.lstat)

I just commented out those lines and was able to install. Once I installed Calibre (brew install --cask calibre) I was able to successfully generate the pdf. As long as you have a recent version of node.js installed, this solution should work. All credit to Flaviocopes for the solution.

@dotnetCarpenter
Copy link
Contributor

@AaronLain Thanks!

For installing Calibre on Linux (also WSL2) see https://calibre-ebook.com/download_linux

I get some errors, like:

├── gitbook-plugin-exercises@3.0.1  invalid (git+https://github.com/MostlyAdequate/plugin-exercises.git#6eb1211ea13fb5731930ff7883d38efe7a743609)
└─┬ gitbook-plugin-include-codeblock@3.1.2  invalid

But book.pdf looks alright to me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants