gitbook-cli icon indicating copy to clipboard operation
gitbook-cli copied to clipboard

Gitbook build stopped to work in node 12.18.3

Open mikyjpeg opened this issue 5 years ago • 39 comments

Since the new version of node, when running gitbook build it fails with the following error:

Installing GitBook 3.2.3

/home/travis/.nvm/versions/node/v12.18.3/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287
      if (cb) cb.apply(this, arguments)
                 ^
TypeError: cb.apply is not a function
    at /home/travis/.nvm/versions/node/v12.18.3/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqCallback.oncomplete (fs.js:169:5)

The command "gitbook install" failed and exited with 1 during .

The command still works fine when using 12.18.2

mikyjpeg avatar Jul 29 '20 11:07 mikyjpeg

Yes, I have the same problem. My node version is v14.6.0

JoeyBling avatar Jul 30 '20 06:07 JoeyBling

I have the same problem.

SadSock avatar Aug 01 '20 19:08 SadSock

I believe the issue was resolved by https://github.com/isaacs/node-graceful-fs/commit/168bdb8f0bb3174e8499d4bc5878deead4172c39, but gitbook-cli has outdated dependencies which pull in versions of graceful-fs without the fix.

rjbeers avatar Aug 03 '20 04:08 rjbeers

I have the same problem, too.

please help.

node version is v14.6.0.

hitzhangjie avatar Aug 03 '20 13:08 hitzhangjie

In light of
https://github.com/GitbookIO/gitbook#%EF%B8%8F-deprecation-warning
We probably need to fork gitbook-cli to maintain it. Who wants to do it?

greyltc avatar Aug 05 '20 12:08 greyltc

@greyltc That sounds good. You can unify one person to fork and then maintain it through the open source community

JoeyBling avatar Aug 06 '20 00:08 JoeyBling

@rjbeers Thank you very much. You're right.

  1. if you run gitbook serve has error and your gitbook-cli is installed globally. Find the NPM global installation directory and into dir node_modules/gitbook-cli/node_modules/npm/node_modules Execute the order

npm install graceful-fs@latest --save

  1. if you run gitbook install has error Go to user directory and into dir .gitbook/versions/3.2.3/node_modules/npm Execute the order

npm install graceful-fs@latest --save

JoeyBling avatar Aug 06 '20 02:08 JoeyBling

@greyltc I noticed a new fork -- https://github.com/greyltc/gitbook-cli/commit/2b39017b9174841e89474c66b884d62fe7a0fdad . Thanks! Are you planning to publish your fork as an npm package? Let me know if I can be any help. Our team depends on gitbook-cli, so I'd love to find a path forward.

zzaacchh avatar Aug 10 '20 20:08 zzaacchh

@zzaacchh I rely on gitbook-cli as well and it's very unfortunate and frustrating that upstream support for it has been dropped (but hey, you can't always have your cake and eat it too!) and I would love a path forward too. I would plan to publish my fork so that the community can have a working gitbook-cli, but I can't get it to work.

The NPM dependancy system seems to be a real nightmare. Any help is welcome.

greyltc avatar Aug 11 '20 10:08 greyltc

Thanks, @greyltc . I'm planning to hire someone on upwork to help fork and repackage. Any chance you'd be up for pitching in on the cost for that?

zzaacchh avatar Aug 14 '20 02:08 zzaacchh

The stuff I use gitbook-cli for is free, open and, non-revenue-generating, so unfortunately I don't have much other than a little of my time to offer. And that's not so valuble here because I don't know shit about javascript!

greyltc avatar Aug 14 '20 19:08 greyltc

I was reached out by @zzaacchh. I’m happy to support this project for free! Forked.

vradars avatar Aug 28 '20 15:08 vradars

I believe the issue was resolved by isaacs/node-graceful-fs@168bdb8, but gitbook-cli has outdated dependencies which pull in versions of graceful-fs without the fix.

yeah it helps !!! my node version is v14.5.0 thanks !!

mxiaole avatar Aug 29 '20 08:08 mxiaole

I ended up to use nvm to use nodejs 10 lts. I updated dependency of graceful-fs globally and locally but it won't help.

kimploo avatar Sep 01 '20 05:09 kimploo

I had the same issue but using different package. It was mentioned before that selective dependency resolution can help with that:

"resolutions": {
  "**/graceful-fs": "^4.2.4"
}

I am installing my deps with yarn and this fixed the issue. I think it's a good idea to double check if the version installed in node_modules is actually 4.2.4 - maybe a lock file or cache keeps installing other version.

rafauke avatar Sep 15 '20 14:09 rafauke

I make my own fork, if you are interested, just use npm i -g gengjiawen/gitbook-cli should work.

I also develop an github action for generate books, please refer to: https://github.com/gengjiawen/koajs-design-note.

gengjiawen avatar Mar 22 '21 09:03 gengjiawen

Still +1

k8w avatar Apr 29 '21 05:04 k8w

I had same problem. I think seems to be dependancy problem with latest version for graceful-fs. Change the graceful-fs version solves the problem.

My environment is :

  • OS : macOS Big Sur
  • node : v12.22.1
  • npm : v6.14.12
  • gitbook-cli : [email protected]
  • graceful-fs : 4.1.4

try this :

$ npm i -g gitbook-cli $ cd /usr/local/lib/node_modules/gitbook-cli $ npm i [email protected] --save $ cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm $ npm i [email protected] --save $ cd {your gitbook directory} $ gitbook init $ gitbook serve

info: 7 plugins are installed info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 1 pages info: found 0 asset files info: >> generation finished with success in 0.2s !

Starting server ... Serving book on http://localhost:4000

jinifor avatar Jun 18 '21 02:06 jinifor

I had same problem. I think seems to be dependancy problem with latest version for graceful-fs. Change the graceful-fs version solves the problem.

My environment is :

  • OS : macOS Big Sur
  • node : v12.22.1
  • npm : v6.14.12
  • gitbook-cli : [email protected]
  • graceful-fs : 4.1.4

try this :

$ npm i -g gitbook-cli $ cd /usr/local/lib/node_modules/gitbook-cli $ npm i [email protected] --save $ cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm $ npm i [email protected] --save $ cd {your gitbook directory} $ gitbook init $ gitbook serve

info: 7 plugins are installed info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 1 pages info: found 0 asset files info: >> generation finished with success in 0.2s ! Starting server ... Serving book on http://localhost:4000

It works for me :) Thanks 😋 @jinifor

  • npm : v7.18.1
  • node : v16.4.0

sbyeol3 avatar Jun 28 '21 09:06 sbyeol3

I had same problem. I think seems to be dependancy problem with latest version for graceful-fs. Change the graceful-fs version solves the problem.

My environment is :

  • OS : macOS Big Sur
  • node : v12.22.1
  • npm : v6.14.12
  • gitbook-cli : [email protected]
  • graceful-fs : 4.1.4

try this :

$ npm i -g gitbook-cli $ cd /usr/local/lib/node_modules/gitbook-cli $ npm i [email protected] --save $ cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm $ npm i [email protected] --save $ cd {your gitbook directory} $ gitbook init $ gitbook serve

info: 7 plugins are installed info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 1 pages info: found 0 asset files info: >> generation finished with success in 0.2s ! Starting server ... Serving book on http://localhost:4000

It works for me too !!! Thanks @jinifor

laurieliyang avatar Jul 21 '21 11:07 laurieliyang

Workaround for me in node:v14.16.0

$ yarn global add [email protected]
$ gitbook fetch 3.2.3

acceptMyPR avatar Aug 03 '21 14:08 acceptMyPR

My node version is v14.0.0 "gitbook install" can success

lianghuipinglz avatar Nov 15 '21 02:11 lianghuipinglz

Just replace the crashing file polyfills.js with this one: https://raw.githubusercontent.com/isaacs/node-graceful-fs/168bdb8f0bb3174e8499d4bc5878deead4172c39/polyfills.js

This works like a charm in Node.js v16.13.0.

nakov avatar Nov 21 '21 21:11 nakov

These are the detailed steps to fix the problem (temporary, just to execute gitbook install and gitbook build):

Install gitbook-cli globally (if not already installed)

npm -g install gitbook-cli

Go to your NPM global modules directory (find its location by typing npm -g list)

Linux: cd /usr/lib/node_modules Windows: cd %AppData%/npm/node_modules

Go to the graceful-fs folder

cd gitbook-cli/node_modules/npm/node_modules/graceful-fs

Delete the old incompatible file polyfills.js, which causes TypeError: cb.apply is not a function

rm polyfills.js

Download a fixed newer version of polyfills.js from GitHub

wget https://raw.githubusercontent.com/isaacs/node-graceful-fs/168bdb8f0bb3174e8499d4bc5878deead4172c39/polyfills.js

nakov avatar Nov 21 '21 21:11 nakov

I had same problem. I think seems to be dependancy problem with latest version for graceful-fs. Change the graceful-fs version solves the problem.

My environment is :

  • OS : macOS Big Sur
  • node : v12.22.1
  • npm : v6.14.12
  • gitbook-cli : [email protected]
  • graceful-fs : 4.1.4

try this :

$ npm i -g gitbook-cli $ cd /usr/local/lib/node_modules/gitbook-cli $ npm i [email protected] --save $ cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm $ npm i [email protected] --save $ cd {your gitbook directory} $ gitbook init $ gitbook serve

info: 7 plugins are installed info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 1 pages info: found 0 asset files info: >> generation finished with success in 0.2s ! Starting server ... Serving book on http://localhost:4000

Great!! It works for me.

MaDolphin avatar Nov 24 '21 19:11 MaDolphin

https://github.com/GitbookIO/gitbook-cli/issues/110#issuecomment-863706455 This works for me too. I'm using M1 mac + homebrew and changed the PATH, so I need to make the following changes.

npm i -g gitbook-cli
cd /opt/homebrew/lib/node_modules/gitbook-cli
npm i [email protected] --save
cd /opt/homebrew/lib/node_modules/gitbook-cli/node_modules/npm
npm i [email protected] --save
cd {your gitbook directory}
gitbook init
gitbook serve

geeknees avatar Jan 30 '22 00:01 geeknees

I had same problem. I think seems to be dependancy problem with latest version for graceful-fs. Change the graceful-fs version solves the problem.

My environment is :

  • OS : macOS Big Sur
  • node : v12.22.1
  • npm : v6.14.12
  • gitbook-cli : [email protected]
  • graceful-fs : 4.1.4

try this :

$ npm i -g gitbook-cli $ cd /usr/local/lib/node_modules/gitbook-cli $ npm i [email protected] --save $ cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm $ npm i [email protected] --save $ cd {your gitbook directory} $ gitbook init $ gitbook serve

info: 7 plugins are installed info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 1 pages info: found 0 asset files info: >> generation finished with success in 0.2s ! Starting server ... Serving book on http://localhost:4000

thank you! it is working...

VaneHay avatar Mar 01 '22 10:03 VaneHay

These are the detailed steps to fix the problem (temporary, just to execute gitbook install and gitbook build):

Install gitbook-cli globally (if not already installed)

npm -g install gitbook-cli

Go to your NPM global modules directory (find its location by typing npm -g list)

Linux: cd /usr/lib/node_modules Windows: cd %AppData%/npm/node_modules

Go to the graceful-fs folder

cd gitbook-cli/node_modules/npm/node_modules/graceful-fs

Delete the old incompatible file polyfills.js, which causes TypeError: cb.apply is not a function

rm polyfills.js

Download a fixed newer version of polyfills.js from GitHub

wget https://raw.githubusercontent.com/isaacs/node-graceful-fs/168bdb8f0bb3174e8499d4bc5878deead4172c39/polyfills.js

that's helpful! I finally manage to install gitbook with node v16.14.1

wanghao6736 avatar Mar 17 '22 12:03 wanghao6736

  • 1

minhnguyenvan95 avatar Apr 06 '22 06:04 minhnguyenvan95

node -v 16.14.2 npm -v 8.5.0 node -v 17.9.0 npm -v 8.7.0

cd C:\Users\admin\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules I tried to install graceful-fs@latest([email protected]), but when I finished, the Gitbook was gone. Finally, [email protected] was installed to fix the problem

Find the global installation directory for NPM: (prefix) C:\Users\admin\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules>npm config ls ; "builtin" config from C:\Users\admin\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\Users\admin\AppData\Roaming\npm"

; "user" config from C:\Users\admin.npmrc

registry = "https://registry.npm.taobao.org/"

; node bin location = C:\Program Files\nodejs\node.exe ; node version = v17.9.0 ; npm local prefix = C:\Users\admin\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm ; npm version = 8.7.0 ; cwd = C:\Users\admin\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules ; HOME = C:\Users\admin ; Run npm config ls -l to show all defaults.

dbhuang avatar Apr 18 '22 11:04 dbhuang