title: Gitbook部署之nodejs踩坑

date: 2020-11-06 16:34:30

summary: Gitbook部署和NVM的使用、hexo失效

Gitbook部署之nodejs踩坑

一、node.js中某版本对Gitbook支持好

(其他版本,很多都是坑)

v12.16.3版本支持很好

D:\___MyGitbook\DOS>node -v
v12.16.3
D:\___MyGitbook\DOS>npm -v
6.14.4

v14.3.0版本不OK

二、第1个坑,安装Gitbook的方式

(1)错误的安装Gitbook的方式

C:\Users\MaxWell> npm install gitbook -g
npm WARN deprecated graceful-fs@3.0.5: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated nunjucks@2.2.0: potential XSS vulnerability in autoescape mode, and with escape filter was fixed in v2.4.3
省略省略省略省略
npm WARN deprecated cryptiles@0.2.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
C:\Users\MaxWell\AppData\Roaming\npm\gitbook -> C:\Users\MaxWell\AppData\Roaming\npm\node_modules\gitbook\bin\gitbook.jsnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^0.3.8 (node_modules\gitbook\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@0.3.8: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + gitbook@2.6.9
added 405 packages from 569 contributors in 118.103s C:\Users\MaxWell>gitbook -v
You need to install "gitbook-cli" to have access to the gitbook command anywhere on your system.
If you've installed this package globally, you need to uninstall it.
>> Run "npm uninstall -g gitbook" then "npm install -g gitbook-cli"

(2)正确的安装Gitbook的方式

//记得在装之前要先卸载
C:\Users\MaxWell>npm uninstall -g gitbook npm WARN deprecated fsevents@0.3.8: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^0.3.8 (node_modules\gitbook\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@0.3.8: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) removed 405 packages in 30.716s //下面是安装命令
C:\Users\MaxWell>npm install -g gitbook-cli C:\Users\MaxWell\AppData\Roaming\npm\gitbook -> C:\Users\MaxWell\AppData\Roaming\npm\node_modules\gitbook-cli\bin\gitbook.js
+ gitbook-cli@2.3.2
added 578 packages from 672 contributors in 72.32s

三、第2个坑,解决安装gitbook时卡顿

在Installing GitBook 3.2.3

我开了VPN还显示

C:\Users\MaxWell>npm install -g gitbook-cli
C:\Users\MaxWell\AppData\Roaming\npm\gitbook -> C:\Users\MaxWell\AppData\Roaming\npm\node_modules\gitbook-cli\bin\gitbook.js
+ gitbook-cli@2.3.2
added 578 packages from 672 contributors in 72.32s C:\Users\MaxWell>gitbook -v C:\Users\MaxWell>gitbook --v error: unknown option `--v' C:\Users\MaxWell>gitbook --version
CLI version: 2.3.2
Installing GitBook 3.2.3
^C终止批处理操作吗(Y/N)?
^C
C:\Users\MaxWell> C:\Users\MaxWell>gitbook -V
CLI version: 2.3.2
Installing GitBook 3.2.3

后面找教程

解决安装gitbook时卡顿在 Installing GitBook 3.2.3 的问题

安装gitbook时卡顿在 Installing GitBook 3.2.3 的问题链接

但是!!!最终,我等了几分钟,等到了

C:\Users\MaxWell>gitbook -V
CLI version: 2.3.2
Installing GitBook 3.2.3
gitbook@3.2.3 AppData\Local\Temp\tmp-7216C6tf0GurtYQJ\node_modules\gitbook
├── escape-string-regexp@1.0.5
├── destroy@1.0.4
├── escape-html@1.0.3
├── ignore@3.1.2
├── bash-color@0.0.4
├── gitbook-plugin-livereload@0.0.1
├省略省略省略省略
├── juice@2.0.0 (deep-extend@0.4.2, slick@1.12.2, batch@0.5.3, cssom@0.3.1, commander@2.9.0, cross-spawn-async@2.2.5, web-resource-inliner@2.0.0)
└── npm@3.9.2
GitBook version: 3.2.3 C:\Users\MaxWell>gitbook -V
CLI version: 2.3.2
GitBook version: 3.2.3

上面表示Gitbook安装成功了

(1)总结这个坑如何避免

1、用VPN,然后耐心等

2、用阿里镜像???(反正我不想用,直接用VPN)本种方式我没有测试过。

四、Gitbook初始化文件

(1)我的没有成功的现象长这样

D:\___MyGitbook\DOS>gitbook init
warn: no summary file in this book
info: create README.md
info: create SUMMARY.md TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Promise

这行出错了

TypeError [ERR_INVALID_ARG_TYPE]:

(2)别人成功的情况

$ gitbook init                #初始化gitbook
warn: no summary file in this book
info: create README.md
info: create SUMMARY.md
info: initialization is finished #初始化成功

(3)查找资料:得知node.js版本的坑!!!(NVM牛皮)

原因

一开始执行gitbook init一直报上面这个错误,后来换了个版本就OK了

根据上面WARN可知系统里安装的node不支持gitbook,然后用nvm(Nodejs版本管理器)切换node版本

1、首先查看自己电脑的node的版本

D:\___MyGitbook\DOS>node -v
v14.3.0

2、寻找命令位置的语句

D:\___MyGitbook\DOS>where node
D:\___MySoftware\05.MyBlog\01.nodejs\01.nodejs\node.exe D:\___MyGitbook\DOS>where tree
C:\WINDOWS\System32\tree.com D:\___MyGitbook\DOS>where gitbook
C:\Users\MaxWell\AppData\Roaming\npm\gitbook
C:\Users\MaxWell\AppData\Roaming\npm\gitbook.cmd

毕竟,注意,我还有本地博客要使用node.js(也就是hexo)

五、卸载当前版本的node.js

1、用win+X+F去卸载

2、删除先前的安装文件夹

D:___MySoftware\05.MyBlog\01.nodejs\01.nodejs

3.检查您的%PATH%环境变量以确保没有引用Nodejs或npm存在。(没有检查到)

然后测试

D:\___MyGitbook\DOS>npm -v
'npm' 不是内部或外部命令,也不是可运行的程序
或批处理文件。 D:\___MyGitbook\DOS>node -v
'node' 不是内部或外部命令,也不是可运行的程序
或批处理文件。 D:\___MyGitbook\DOS>where node
信息: 用提供的模式无法找到文件。

六、安装NVM

NVM安装网站

1、NVM安装网站

2、实际链接

3、我还备份一份到我的图床中。

NVM常用命令

NVM常用命令

安照文章进行设置,一路安装。

打开新的cmd。测试

在新的命令窗口中输入nvm

C:\Users\MaxWell>nvm

Running version 1.1.7.

Usage:

  nvm arch                     : Show if node is running in 32 or 64 bit mode.
nvm install <version> [arch] : The version can be a node.js version or "latest" for the latest stable version.
Optionally specify whether to install the 32 or 64 bit version (defaults to system arch).
Set [arch] to "all" to install 32 AND 64 bit versions.
Add --insecure to the end of this command to bypass SSL validation of the remote download server.
nvm list [available] : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.
nvm on : Enable node.js version management.
nvm off : Disable node.js version management.
nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.
Set [url] to "none" to remove the proxy.
nvm node_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.
nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.
nvm uninstall <version> : The version must be a specific version.
nvm use [version] [arch] : Switch to use the specified version. Optionally specify 32/64bit architecture.
nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.
nvm root [path] : Set the directory where nvm should store different versions of node.js.
If <path> is not set, the current root will be displayed.
nvm version : Displays the current running version of nvm for Windows. Aliased as v.

七、测试NVM

C:\Users\MaxWell>nvm

Running version 1.1.7.

Usage:

 省略省略省略
nvm version : Displays the current running version of nvm for Windows. Aliased as v. //目前还没有用NVM安装任何node版本????什么情况,后面就知道了
C:\Users\MaxWell>nvm ls No installations recognized. //用NVM安装最新的64位版本的node,主要是继续维持我的hexo能运转
C:\Users\MaxWell>nvm install latest 64
Downloading node.js version 15.0.1 (64-bit)...
Complete
Creating D:\___MySoftware\05.MyBlog\03.Nvm\03.Nvm\nvm\temp Downloading npm version 7.0.3... Complete
Installing npm v7.0.3... Installation complete. If you want to use this version, type nvm use 15.0.1 C:\Users\MaxWell>npm -v
'npm' 不是内部或外部命令,也不是可运行的程序
或批处理文件。 C:\Users\MaxWell>nvm which 15.0.1 Running version 1.1.7. Usage: nvm arch : Show if node is running in 32 or 64 bit mode.
nvm install <version> [arch] : The version can be a node.js version or "latest" for the latest stable version.
Optionally specify whether to install the 32 or 64 bit version (defaults to system arch).
Set [arch] to "all" to install 32 AND 64 bit versions.
Add --insecure to the end of this command to bypass SSL validation of the remote download server.
nvm list [available] : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.
nvm on : Enable node.js version management.
nvm off : Disable node.js version management.
nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.
Set [url] to "none" to remove the proxy.
nvm node_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.
nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.
nvm uninstall <version> : The version must be a specific version.
nvm use [version] [arch] : Switch to use the specified version. Optionally specify 32/64bit architecture.
nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.
nvm root [path] : Set the directory where nvm should store different versions of node.js.
If <path> is not set, the current root will be displayed.
nvm version : Displays the current running version of nvm for Windows. Aliased as v.

八、NVM的安装列表——查看安装了哪些版本的node

C:\Users\MaxWell>nvm list

    15.0.1

C:\Users\MaxWell>nvm use 15.0.1
Now using node v15.0.1 (64-bit) C:\Users\MaxWell>node -v
v15.0.1 C:\Users\MaxWell>npm -V
^C终止批处理操作吗(Y/N)?
^C^C终止批处理操作吗(Y/N)?
^C C:\Users\MaxWell>npm -v
npm notice
npm notice New patch version of npm available! 7.0.3 -> 7.0.6
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.0.6
npm notice Run npm install -g npm@7.0.6 to update!
npm notice
7.0.3

十、坑爹,好像以前的npm装的都没有了(所以-先装NVM再装Nodejs)

D:\___MyGitbook\DOS>gitbook init
'gitbook' 不是内部或外部命令,也不是可运行的程序
或批处理文件。 D:\___MyGitbook\DOS>gitbook -v
'gitbook' 不是内部或外部命令,也不是可运行的程序
或批处理文件。 D:\___MyGitbook\DOS>gitbook -V
'gitbook' 不是内部或外部命令,也不是可运行的程序
或批处理文件。 D:\___MyGitbook\DOS>where gitbook
信息: 用提供的模式无法找到文件。 D:\___MyGitbook\DOS>

十一、以防万一,顺路安装一个似乎可以用gitbook的版本的node

C:\Users\MaxWell>npm -v
npm notice
npm notice New patch version of npm available! 7.0.3 -> 7.0.6
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.0.6
npm notice Run npm install -g npm@7.0.6 to update!
npm notice
7.0.3 C:\Users\MaxWell>nvm install v12.16.3
Downloading node.js version 12.16.3 (64-bit)...
Complete
Creating D:\___MySoftware\05.MyBlog\03.Nvm\03.Nvm\nvm\temp Downloading npm version 6.14.4... Complete
Installing npm v6.14.4... Installation complete. If you want to use this version, type nvm use 12.16.3 C:\Users\MaxWell>
C:\Users\MaxWell>npm -v
7.0.3 C:\Users\MaxWell>nvm list * 15.0.1 (Currently using 64-bit executable)
12.16.3 C:\Users\MaxWell>nvm use 12.16.3
Now using node v12.16.3 (64-bit) C:\Users\MaxWell>

十二、用当前版本node v12.16.3 (64-bit)的npm安装gitbook

C:\Users\MaxWell>npm -v

6.14.4

C:\Users\MaxWell>npm -v
6.14.4 C:\Users\MaxWell>npm install gitbook -g
npm WARN deprecated graceful-fs@3.0.5: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated nunjucks@2.2.0: potential XSS vulnerability in autoescape mode, and with escape filter was fixed in v2.4.3
npm WARN deprecated chokidar@1.0.6: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated request@2.51.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated fsevents@0.3.8: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated sprintf@0.1.5: The sprintf package is deprecated in favor of sprintf-js.
npm WARN deprecated datauri@0.2.1: Datauri 2.0 released. See more in https://github.com/data-uri/datauri/releases/tag/v2.0.0
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated hawk@1.1.1: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated sntp@0.2.4: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated cryptiles@0.2.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@0.9.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated boom@0.4.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
C:\Program Files\nodejs\gitbook -> C:\Program Files\nodejs\node_modules\gitbook\bin\gitbook.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^0.3.8 (node_modules\gitbook\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@0.3.8: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + gitbook@2.6.9
added 405 packages from 569 contributors in 79.58s
C:\Users\MaxWell>npm install -g gitbook-cli
C:\Program Files\nodejs\gitbook -> C:\Program Files\nodejs\node_modules\gitbook-cli\bin\gitbook.js
+ gitbook-cli@2.3.2
added 578 packages from 672 contributors in 63.485s C:\Users\MaxWell>gitbook -V
CLI version: 2.3.2
GitBook version: 3.2.3

十三、完美用低版本修复Gitbook的bug

D:\___MyGitbook\DOS>gitbook init
warn: no summary file in this book
info: create README.md
info: create SUMMARY.md
info: initialization is finished D:\___MyGitbook\DOS>node -v
v12.16.3 D:\___MyGitbook\DOS>npm -v
6.14.4 D:\___MyGitbook\DOS>

Gitbook部署之nodejs踩坑的更多相关文章

  1. Solr 7 部署与使用踩坑全记录

    前言 Solr 是一种可供企业使用的.基于 Lucene 的搜索服务器,它支持层面搜索.命中醒目显示和多种输出格式.在这篇文章中,我将介绍 Solr 的部署和使用的基本操作,希望能让初次使用的朋友们少 ...

  2. NodeJS踩坑实录

    nodejs的常用api url 主要是配置一系列和路径相关的信息 url.parse(urlString[, parseQueryString[, slashesDenoteHost]]) 将一个U ...

  3. Mac系统STF自动化环境搭建及部署踩坑记录

    因为公司需要寻找一个免root的自动化测试方案,所以以前做的老方案需要被替代.一阵搜寻找到了这个框架,但是部署起来很是折腾,搞了一下午终于搞定,顺便记录一下过程,有需要的自取. 转载请注明出处:htt ...

  4. 【踩坑经历】一次Asp.NET小网站部署踩坑和解决经历

    2013年给1个大学的小客户部署过一个小型的Asp.NET网站,非常小,用的sqlite数据库,今年人家说要换台服务器,要重新部署一下,好吧,虽然早就过了服务时间,但无奈谁叫人家是客户了,二话不说,上 ...

  5. React Native Android配置部署踩坑日记

    万事开头难 作为一只进入ECMAScript世界不久的菜鸟,已经被React Native的名气惊到了,开源一周数万星勾起了我浓烈的兴趣.新年新气象,来个HellWorld压压惊吧^_^(故意少打个' ...

  6. github webhook 实现代码自动部署 踩坑!! 附加git&coding webhook部署代码

    踩坑: 1.php程序执行linux命令是以webserver的user用户(如apache .www……)操作的,需要在/etc/sudoers添加用户免密码操作权限; %apache ALL=(A ...

  7. C# -- HttpWebRequest 和 HttpWebResponse 的使用 C#编写扫雷游戏 使用IIS调试ASP.NET网站程序 WCF入门教程 ASP.Net Core开发(踩坑)指南 ASP.Net Core Razor+AdminLTE 小试牛刀 webservice创建、部署和调用 .net接收post请求并把数据转为字典格式

    C# -- HttpWebRequest 和 HttpWebResponse 的使用 C# -- HttpWebRequest 和 HttpWebResponse 的使用 结合使用HttpWebReq ...

  8. 记一次Docker中部署Asp.Net Core 3.0的踩坑过程

    最近公司打算重构目前直销报单系统到微信小程序中,目前的系统只能在PC上面使用,这两年也搞过App端,但是由于人员流动和公司架构调整最后都不了了之,只留下一堆写了一半的接口.以前的接口依然是使用Asp. ...

  9. IdentityServer 部署踩坑记

    IdentityServer 部署踩坑记 Intro 周末终于部署了 IdentityServer 以及 IdentityServerAdmin 项目,踩了几个坑,在此记录分享一下. 部署架构 项目是 ...

  10. Docker 部署 redis教程,附带部分小建议,防止踩坑

    Docker 部署 redis,附带部分小建议,防止踩坑 跟所有人一样,我们先从docker基本命令开始 一.拉取redis镜像(配图来自菜鸟,其实截图没多大意义,对比看下) # 默认就拉取laste ...

随机推荐

  1. org.springframework.web.filter.CharacterEncodingFilter cannot be cast to javax.servlet.Filter异常

    转:https://blog.csdn.net/u010670689/article/details/40301043 使用maven开发web应用程序, 启动的时候报错: jar not loade ...

  2. 有序数组的平方&长度最小的子数组&螺旋矩阵Ⅱ

    一.有序数组的平方 977.有序数组的平方 leetcode链接 1.方法概述 双"指针"解法:因为数组本来是有序的,平方后可能出现的两端大数值大的情况.所以从数组两端开始遍历,谁 ...

  3. 聊一聊HTTPS双向认证的简单应用

    目录 背景 准备工作 ASP.NET Core nginx 反向代理 IIS 部署 总结 参考资料 背景 在三方接口对接中,偶尔会遇到需要传递证书的情况,这种方式其实是在SSL握手过程中会同时验证客户 ...

  4. SRS视频流服务器初试

    目录 1.关于协议理解 2.快速开始 1.SRS安装 2.推流 3.拉流 注: 1)方式一:SRS网页播放器(推荐) 2)方式二:VLC播放器(需要下载,延迟高,不推荐) 1.关于协议理解 在前面的博 ...

  5. yaml文件详解

    一.yaml文件详解 前言 Kubernetes 支持 YAML 和 JSON 格式管理资源对象JSON 格式:主要用于 api 接口之间消息的传递YAML 格式:用于配置和管理,YAML 是一种简洁 ...

  6. vant ui rem配置流程

    参考地址  https://www.cnblogs.com/WQLong/p/7798822.html 1.下载lib-flexible 使用的是vue-cli+webpack,通过npm来安装的 n ...

  7. TCP/IP协议(3): Wi-Fi(IEEE 802.11) 协议 —— 构成无线局域网的基本协议

    TCP/IP协议(3): Wi-Fi(IEEE 802.11) 协议 -- 构成无线局域网的基本协议 关于 Wi-Fi(IEEE 802.11) 协议 关于 IEEE 802.11 IEEE 802. ...

  8. C++梳理

    1.基础篇 1.C++ 中的四种智能指针 为什么要使⽤智能指针:智能指针其作⽤是管理⼀个指针,避免程序员申请的空间在函数结束时忘记释放,造成内存泄漏这种情况的发⽣.使⽤智能指针可以很⼤程度上的避免这个 ...

  9. CCRD_TOC_2007_EULAR专辑_1

    中信国健临床通讯 EULAR 2007专辑I 目 录 类风湿关节炎 1 TEMPO 研究第一年影像学数据显示:骨侵蚀修复 (repair) 几乎只出现在无关节肿胀或肿胀改善组 van der Heij ...

  10. 网页js版音频数字信号处理:H5录音+特定频率信号的特征分析和识别提取

    目录 一.网页中的音频数据源 二.FFT:时域转频域 三.信号的特征分析 四.信号的识别提取 附录 音频数字信号处理 Audio DSP (Digital Signal Processing) 是一个 ...