使用sinopia搭建npm私有倉庫
1、安裝 Node 環(huán)境
a、官網(wǎng)下載 tar 包
b、解壓設(shè)置環(huán)境變量
PATH=/usr/local/node/bin:$PATH
2、安裝 sinopia
npm install -g sinopia
3、初次手動啟動服務(wù)生成配置文件
$ sinopia
Sinopia doesn't need superuser privileges. Don't run it under root.
warn --- config file - /root/.config/sinopia/config.yaml
warn --- http address - http://0.0.0.0:4873/
4、修改配置文件
vim /root/.config/sinopia/config.yaml
grep -v "^$" config.yaml | grep -v "^\s*#"
storage: /home/sinopia/storage
auth:
htpasswd:
file: /home/sinopia/htpasswd
max_users: -1
uplinks:
npmjs:
url: http://registry.npm.taobao.org
packages:
'@*/*':
access: $all
publish: $authenticated
proxy: npmjs
'*':
access: $all
publish: $authenticated
proxy: npmjs
logs:
- {type: stdout, format: pretty, level: http}
- {type: file, path: /home/sinopia/logs/sinopia.log, level: info}
listen: 0.0.0.0:4873 # 默認(rèn)沒有,只能本機localhost訪問,添加后可以通過外網(wǎng)訪問
max_body_size: 50mb
5、安裝 pm2 用于后臺啟動
npm install -g pm2
6、使用 pm2 啟動 sinopia
pm2 start `which sinopia`
pm2 ls
7、安裝 nrm 用于管理鏡像站點
npm install -g nrm
nrm ls
nrm add cloudpath http://172.20.47.76:4873
nrm use cloudpath
8、添加用戶
npm adduser --registry http://172.20.47.76:4873
9、嘗試發(fā)布一個包
mkdir test
cd test
npm init -y
npm publish
10、打開頁面查看
http://172.20.47.76:4873/
效果如下:

同類產(chǎn)品還有 verdaccio
參考:
浙公網(wǎng)安備 33010602011771號