Hello, I’m Yue Chuang.

Install gitbook tutorial many, I will not expand here in detail, you can click this link to view: www.aiyc.top/1947.html if the link is invalid, you can leave a message.

Here are some of the potholes I encountered installing Gitbook.

1. Problem: Gitbook installation appears

TypeError: cb.apply is not a function 
Copy the code

Solution: Demote NodeJS

If (cb) cb.apply(this, arguments), cb.apply is not a function

First, using gitbook Init, you get stuck in the stage of Gitbook 3.2.3

Solutions:

  1. Over the wall
  2. Download using Taobao image:
  3. NPM download path, check whether taobao mirror:
npm config get registry
npm config set registry https://registry.npm.taobao.org
Copy the code

Switch to Taobao mirror

Check again is not taobao mirror:

npm config get registry
Copy the code

To install:

gitbook init
Copy the code

I have been stuck here before, I typed three pieces of code is not good!! After setting up, playing a game, looking back, it came out!

But error!! But it’s another sad story…

If (cb) cb.apply(this, arguments), cb.apply is not a function

The following error is generated:

This error occurs because the nodeJS version is incorrect and does not support the Gitbook.

There are two solutions:

Switch the nodejs version:

Switching to nodeJS version V10.21.0 will work.

Of course, here, I have access to new knowledge! Because there are many versions of NodeJS, there is a nodeJS version control tool that can easily switch between versions!

This is the blog address for this method, www.aiyc.top/1946.html

Second, the second method, which is more convenient and shameless, is to comment out the error code! Open the error file directly:

C:\Users\Administrator\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills. js

The error is in line 287 of the code, which is the function begging for help!!

function statFix (orig) {
  if(! orig) return orig // Older versions of Node erroneously returned signed integersfor
  // 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)
    })
  }
}
Copy the code

This function is used to fix some node.js bugs, but I don’t need to be hard on myself just to learn gitbook!

So, I find the call to this function:

That’s it! Hey hey ~

2. Problem: use Gitbook compiled formula to display as source code

Solution: Install the MathJax plug-in

  1. About Mathjax suddenly not working

Warning: I did not understand the principle of this problem, it is confused and solved, please watch carefully

At first I wanted to use Mathjax to write math formulas in Gitbook, but I followed the online steps

The first step is to have a Node.js environment

The root directory creates the book.json file

{plugins: [” mathJax “]; }

Then the root directory executes gitbook install./

So my problem is that I can’t download it. Maybe I really need to wait for a while, but I’m a hothead. I Google directly and find an article: www.aiyc.top/1979.html

Gitbook officially no longer maintains plugins, mathJax has a problem with the official mirror of Gitbook mathjax due to shutting down the CDN.

So a plugin, gitbook-plugin-MathJax-Pro, is written here

{
    "plugins": ["mathjax-pro"]
}
Copy the code
  • Final installation:gitbook install ./

This time it worked, but when I used the same method for the second book, the download succeeded, but generated the book with an error:

Error with plugin “mathJAX-Pro” : Cannot find module ‘mathJax/Unpacked/mathjax

Continue to check, this time on baidu, found this article: zhuanlan.zhihu.com/p/125577482

Mathjax generates an error when generating a PDF or web page. This error occurs when mathJax is newly installed or updated. The solution is to downgrade MathJax and install version 2.7.6

NPM install [email protected]

Then I just ran NPM install [email protected] directly from the root directory

Then continue to gitbook serve

Here’s what markdown said:

## 3. Classification of subqueries
+ **IN / NOT IN**The subquery;+$$\ theta-some / \ theta-all $$subquery;+ **EXISTS / NOT EXISTS**The subquery;Copy the code

The results were perfect:

3. Problem: MathJax installation fails

PluginError: Error with plugin "mathjax-pro": Cannot find module 'mathjax/unpacked/MathJax'
Copy the code

Solution: Install [email protected]

Same as above!

4. Problem: An installation error occurs

npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\username\package.json'
Copy the code

Solution: Execute named NPM init first

NPM WARN saveError ENOENT: No such file or directory

After installing Node.js, use NPM to install vue.

C:\Users\lxz>npm uninstall vueWcsp
npm WARN saveError ENOENT: no such file or directory.open 'C: \Users\lxz\package.json'
npm WARN enoent ENOENT: no such file or directory.open 'C: \Users\lxz\package.json'
npm WARN lxz No description
npm WARN lxz No repository field.
npm WARN lxz No README data
npm WARN lxz No license field.
 
 
up to date in 0.765s
Copy the code

According to the error message, the system does not have the file ‘package.json’. The purpose of this file is to manage your locally installed NPM packages. A package.json file can do the following:

Show the NPM packages that the project depends on

Allows you to specify a package version [scope]

Allowing you to build stability means you can better share it with other developers

Now we need to execute the command:

npm init
Copy the code

Create package.json and you will be prompted for the configuration. You can also use the following command:

npm init -y
Copy the code

Create package.json file directly. The advantage of creating package.json file is that the required fields have been filled in for you.

More on Gitbook:

  1. www.chengweiyang.cn/gitbook/ind…
  2. note.heifahaizei.com/book/
  3. Juejin. Cn/post / 693122…
  4. Chrisniael. Gitbooks. IO/gitbook – doc…
  5. Yangjh. Oschina. IO/gitbook/FAQ… There are quiz function tutorials
  6. learn-gitbook.gitbook.io/gitbook/
  7. Allen5183. Gitbooks. IO/gitbook/con… With 5

AI Yue Chuang ·V: Jiabcdefh

Official account: AI Yue Chuang