使用verdaccio搭建私有npm源 解决npm install 失败的问题

安装
1.官网 https://verdaccio.org/docs/installation/
2.config.yaml配置说明
需要格外注意的是必须配置 listen: 0.0.0.0:4873 才能运行其他机子访问
在离线时要发布依赖包必须设置 allow_offline: true
#--------------------------------------------------
# #号后面是注释
# 所有包的缓存目录
storage: ./storage
# 插件目录
plugins: ./plugins

#开启web 服务,能够通过web 访问
web:
# WebUI is enabled as default, if you want disable it, just uncomment this line
#enable: false
title: Verdaccio
#验证信息
auth:
htpasswd:
# 用户信息存储目录
file: ./htpasswd
# Maximum amount of users allowed to register, defaults to "+inf".
# You can set this to -1 to disable registration.
#max_users: 1000

# a list of other known repositories we can talk to
#公有仓库配置
uplinks:
npmjs:
url: https://registry.npmjs.org/

packages:
'@*/*':
# scoped packages
access: $all
publish: $authenticated

#代理 表示没有的仓库会去这个npmjs 里面去找 ,
#npmjs 又指向 https://registry.npmjs.org/ ,就是上面的 uplinks 配置
proxy: npmjs

'**':
# 三种身份,所有人,匿名用户,认证(登陆)用户
# "$all", "$anonymous", "$authenticated"

#是否可访问所需要的权限
access: $all

#发布package 的权限
publish: $authenticated

# 如果package 不存在,就向代理的上游服务发起请求
proxy: npmjs

# To use `npm audit` uncomment the following section
middlewares:
audit:
enabled: true
# 监听的端口 ,重点, 不配置这个,只能本机能访问
listen: 0.0.0.0:4873
# 允许离线发布
publish:
allow_offline: true
# log settings
logs:
- {type: stdout, format: pretty, level: http}
#- {type: file, path: verdaccio.log, level: info}
#-------------------------------------------------------------

3.添加用户并设置npm镜像源
#当前npm 服务指向本地
npm set registry http://localhost:4873
# 注册用户 在本地注册一个用户然后指向我们的地址然后我们就可以发布包了
npm adduser --registry http://xxx:4873
Username: xxx
Password: xxx
Password: xxx
Email: (this IS public) xxx
Logged in as yg-ui on http://xxx/ (你的ip地址)
这时候我们就注册一个用户,我们可以用这个用户名和密码去登录去上图窗口去登录了

4.参考
https://segmentfault.com/a/1190000023213407

错误处理
OpenSSL SSL_read: Connection was reset, errno 10054 code 128
处理
1.git config --global http.sslVerify "false"
2.git config --global url."https://".insteadOf git://
3.项目用的包全部单独安装一次 判断是哪个包的问题 在单独安装包的依赖

!第二项有时候会出现问题 要切换回来才能安装部分包

 

1.查看Git所有配置

git config --list

2.删除全局配置项

(1)终端执行命令:

git config --global --unset user.name

(2)编辑配置文件:

git config --global --edit