0%

ubuntu 20.04 GitBook 升级

ubuntu 20.04GitBook 运行出现错误

$ gitbook serve
Live reload server started on port: 35729
Press CTRL+C to quit ...

/usr/local/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 /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqCallback.oncomplete (fs.js:184:5)

本质原因部分包版本不匹配,需要重新安装 GitBook

  • 卸载现有版本

    $ gitbook ls
    GitBook Versions Installed:
    
      * 3.2.3
        2.6.9
    

Run “gitbook update” to update to the latest version.

$ gitbook uninstall 2.6.9
GitBook 2.6.9 has been uninstalled.

$ gitbook uninstall 3.2.3
GitBook 3.2.3 has been uninstalled.

- Install
```shell
$ gitbook ls-remote
$ gitbook fecth 3.2.3
Installing GitBook 3.2.3
/usr/local/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 /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqCallback.oncomplete (fs.js:184:5)
  • update graceful-fs
    $ cd /home/<USER_NAME>/.nvm/versions/node/v14.17.1/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/
    $ sudo npm install graceful-fs@4.2.0 --save
  • Reinstall
    $ gitbook fecth 3.2.3