使用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