---
# System prepended metadata

title: GitBook安裝與啟動

---

# GitBook安裝與啟動




### 1. 安装Node.js
```
sudo apt install npm
```
### 2. 安装gitbook-cli
```
npm install -g gitbook-cli
```
- 安裝的資料夾有需要的話```sudo chmod 777 <資料夾名稱>```
- 產生node_modules資料夾
#### 查看gitbook版本
```
gitbook -V
```
---

### 3. 初始化書籍
```
gitbook init
```
- 指令下完會建立
    - README.md
    - SUMMARY.md
    - _book資料夾

- 找到的docker-compose.yml
    ``` 
    version: "3"
    services:
      gitbook:
        image: fellah/gitbook
        container_name: gitbook
        ports:
          - "4000:4000"
        volumes:
          #- ./gitbook:/srv/gitbook
          - ./book:/srv/gitbook
          - ./book/SUMMARY.md:/srv/gitbook/SUMMARY.md
          - ./book/README.md:/srv/gitbook/README.md
          - ./book/files:/srv/gitbook/files
    ```

- 插件book.json
    - 與docker-compose.yml同一層
    - 增加or減少都在這邊撰寫
    - 完成後下指令```gitbook install```
    - 一樣會產生node_modules資料夾
        ```
        "plugins": [
            "-lunr",
            "-search",
            "search-pro",
            "chapter-fold",
            "expandable-chapters",
            "splitter",
            "back-to-top-button",
            "hide-element",
            "chapter-numbering",
            "code",
            "popup",
            "youtubex",
            "click-reveal",
            "auto-scroll-table",
            "pageview-count",
            "todo",
            "ancre-navigation",
            "flexible-alerts",
            "js-sequence-diagram-full@>=0.3.1",
            "mermaid"
          ]
        ```

### 4. 建構書籍
- 在有README.md的那一層下指令
```
gitbook build
```

### 5. 啟動書籍
- 在有README.md的那一層下指令
```
gitbook serve
```

### 6. 瀏覽gitbook
- 於瀏覽器打開 



###### tags: `gitbook`