【Verdaccio】 搭建私有 npm 仓库

背景

公司内部封装业务相关的组件库,工具库,希望统一管理和维护,在多个项目中都能使用,同时希望不公开,只在局域网中使用。所以,需要搭建私有 npm 仓库

Verdaccio

verdaccio 是一个能够创建私有 registry(仓库)的工具

下面是官方介绍

Verdaccio is a simple, zero-config-required local private NPM registry. No need for an entire database just to get started. Verdaccio comes out of the box with its own tiny database, and the ability to proxy other registries (eg. npmjs.org), also introduces caching the downloaded modules along the way. For those who are looking to extend their storage capabilities, Verdaccio supports various community-made plugins to hook into services such as Amazon’s S3, Google Cloud Storage or create your own plugin.

特点

  • 使用私有库
  • 关联多个仓库
  • 提供缓存功能
  • 覆盖公有库

安装

使用 npm 全局安装

npm install -g verdaccio

运行

安装后直接运行 verdaccio

verdaccio

此时打开 http://localhost:4873/,这是地址就是我们的 registry 地址,此时可以看到我们还未发布任何包的界面

在这里插入图片描述

设置仓库地址

  • 方法一 ,直接设置
npm config set registry=http://localhost:4873/
  • 方法二,使用 nrm 管理我们的仓库地址

全局安装 nrm

npm install -g nrm

把私有仓库地址添加 nrm

nrm add myregsitry http://localhost:4873/

切换到私有仓库

nrm use myregistry

创建用户

npm adduser

输入用户名地址邮箱完成注册

登入

npm login

发布

在你的私有库目录中运行

npm publish

可以看到发布成功
在这里插入图片描述

查看

在这里插入图片描述
可以看到发布成功啦。

使用

先确保我们使用的是私有库

nrm use myregistry
npm install to-chinese
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值