GitBook 安装、删除、卸载及常见错误 command not found,npm ERR! syscall symlink

Gitbook 安装

Gitbook 安装过程中遇到的一些问题及卸载方法和基本错误解决办法
如-bash: gitbook: command not found
如 npm ERR! EEXIST: file already exists, symlink 等

1.Node安装

有些版本是不兼容的,所以要确定你安装的 node 什么版本, 没用brew 可以尝试用下,你会发现用了以后,爱不释手

#查看可以安装的node版本
brew search node
#安装制定版本node
brew install node@10
#安装完毕 查看node版本
node -v
#安装完毕 查看npm版本
npm -v

看下结果

jiazijie ~ $ brew search node
==> Formulae
libbitcoin-node   llnode            node              node-build        node-sass         node@10 ✔         node@12           node_exporter     nodebrew          nodeenv           nodenv
==> Casks
nodebox                                                                                                nodeclipse

If you meant "node" specifically:
It was migrated from homebrew/cask to homebrew/core.


jiazijie ~ $ brew install node@10
Updating Homebrew...
Warning: node@10 10.21.0 is already installed and up-to-date
To reinstall 10.21.0, run `brew reinstall node@10`


jiazijie ~ $ node -v
v10.21.0
jiazijie ~ $ npm -v
6.14.4

2.Gitbook 安装

正常来说 安装很简单,但是 顶不住 遇到的各种问题啊

#安装 gitbook
npm install -g gitbook
#安装 gitbook-cli
# 可能会出现问题
npm install -g gitbook-cli 

3.Gitbook 问题

1. npm ERR! EEXIST: file already exists, symlink

出现
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! EEXIST: file already exists

npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/gitbook-cli/bin/gitbook.js
npm ERR! dest /Users/jiazijie/npm-global/bin/gitbook
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/gitbook-cli/bin/gitbook.js' -> '/Users/jiazijie/npm-global/bin/gitbook'
npm ERR! File exists: /Users/jiazijie/npm-global/bin/gitbook
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jiazijie/.npm/_logs/2020-07-20T07_12_12_294Z-debug.log
解决办法:

sudo npm install -g gitbook-cli --force 输入密码,管理员安装

jiazijie ~ $ sudo npm install -g gitbook-cli --force
Password:
npm WARN using --force I sure hope you know what you are doing.
/Users/jiazijie/npm-global/bin/gitbook -> /Users/jiazijie/npm-global/lib/node_modules/gitbook-cli/bin/gitbook.js
+ [email protected]
added 578 packages from 672 contributors in 10.168s
2. gitbook: command not found

出现 gitbook -V -bash: gitbook: command not found
先看下日志,自己的 gitbook是否成功安装 日志中有路径
/Users/jiazijie/npm-global/bin/gitbook -> /Users/jiazijie/npm-global/lib/node_modules/gitbook-cli/bin/gitbook.js
[email protected]

切到路径下,看到 gitbook命令是 存在的

jiazijie ~ $ cd /Users/jiazijie/npm-global/bin/
jiazijie bin $ ll
total 0
lrwxr-xr-x  1 jiazijie  staff  33  7 17 17:10 cnpm -> ../lib/node_modules/cnpm/bin/cnpm
lrwxr-xr-x  1 jiazijie  staff  46  7 20 15:14 gitbook -> ../lib/node_modules/gitbook-cli/bin/gitbook.js
lrwxr-xr-x  1 jiazijie  staff  27  7 17 18:39 n -> ../lib/node_modules/n/bin/n
lrwxr-xr-x  1 jiazijie  staff  44  7 17 17:07 node-gyp -> ../lib/node_modules/node-gyp/bin/node-gyp.js
解决办法

?????????? 路径存在但是 执行不了 ????不慌!!!
打开你的 .bash_profile文件 一般在你的 用户目录下,编辑一下
在这里插入图片描述

cd ~/
vim .bash_profile
# 找到里面的变量 path 加上 :$(npm prefix -g)/bin 
# 记得在最后的export PATH 上加, 还有 : 冒号不要漏掉 
# 不要抄我的变量,只需要在后面加这个就可以,没有PATH 就新建一个  ,编辑完 这个样子
export PHANTOMJS_HOME=/usr/local/phantomjs/bin
export PATH=$PATH:$JAVA_HOME:$BISON_HOME:$MAVEN_HOME/bin:$RBMQ_HOME:$MYSQL_HOME:$PHANTOMJS_HOME:$(npm prefix -g)/bin

#然后执行 ,刷新变量
source .bash_profile


#在看下效果  -V 大写的 V
jiazijie ~ $ gitbook -V
CLI version: 2.3.2
GitBook version: 3.2.3

这样 就可以了在这里插入图片描述

4.Gitbook 卸载删除

npm uninstall -g gitbook
npm uninstall -g gitbook-cli
npm cache clean -f

猜你喜欢

转载自blog.csdn.net/u010134642/article/details/107460372