node 私仓搭建了解
cd /opt
tar -zxvf node-v16.14.2-linux-x64.tar.xz
mv node-v16.14.2-linux-x64 nodejs
ll nodejs/bin/
ln -s /opt/nodejs/bin/* /usr/local/bin/
node -v
npm config set registry https://registry.npm.taobao.org/
npm i -g verdaccio
npm i -g pnpm # 安装插件【选】
npm i -g yarn # 安装插件【选】
修改安装源
npm config set registry http://localhost:4873/
mkdir /root/.config/verdaccio
cd /root/.config/verdaccio
pm2 start /opt/nodejs/bin/verdaccio
[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /opt/nodejs/bin/verdaccio in fork_mode (1 instance)
[PM2] Done.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 0 │ verdaccio │ fork │ 0 │ online │ 0% │ 15.4mb │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
vim config.yaml #启动覆盖了原始的配置,启动后修改
storage: /opt/verdaccio/storage
plugins: /opt/verdaccio/plugins
web:
title: Verdaccio
i18n:
web: zh-CN
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
taobao:
url: https://registry.npm.taobao.org/
packages:
'@*/*':
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
'**':
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
server:
keepAliveTimeout: 60
middlewares:
audit:
enabled: true
logs: { type: stdout, format: pretty, level: http }
#监听的端口,让同一网络下的所有计算机访问
listen: 0.0.0.0:4873
[root@vm storage]# npm set registry http://localhost:4873
[root@vm storage]# npm adduser --registry http://localhost:4873
Username: test01
Password:
Email: (this IS public) 123456@qq.com
pm2 restart /opt/nodejs/bin/verdaccio
ss -antup | grep 4873
tcp LISTEN 0 128 *:4873 *:* users:(("Verdaccio",pid=45))
http://localhost:4873/
test01/123456 配置里你可以看到 npm yarn pnpm 包管理工具的配置
启动 pm2 start /opt/nodejs/bin/verdaccio
重启 pm2 restart /opt/nodejs/bin/verdaccio
重载 pm2 reload /opt/nodejs/bin/verdaccio
停止 pm2 stop /opt/nodejs/bin/verdaccio
删除 pm2 delete /opt/nodejs/bin/verdaccio
展示 pm2 show /opt/nodejs/bin/verdaccio
列表 pm2 list
npm login
test01 123456
npm 仓库设置
npm set registry http://localhost:4873
npm adduser --registry http://localhost:4873 #npm 添加用户
npm publish #npm 发布
npm publish --registry http://localhost:4873
npm unpublish 包名 --force