Frontier公司做项目比较多的时候,会孵化出一套内部业务组件库。我们不想把这些企业级的组件上传到公共的npm仓库,这个时候企业级私有的npm就更重要了,Verdaccio可以很简单,可以帮助我们零构建一个企业级的私有npm库配置官网地址:https://verdaccio.org///当前githubstar为13Kgithub地址:https://github.com/verdaccio/verdaccioinstallation//全局安装npminstall-gverdaccio//安装verdaccio后//在命令行上执行verdaccio,我们看到如下结果默认是在4873端口启动,我们在浏览器中输入http://localhost:4873可以看到默认的启动界面。启动界面配置修改我们打开/Users/storm/.config/verdaccio/config.yaml目录下的文件,下面是我编译的默认配置存储:./storageplugins:./pluginsweb:title:Verdaccioauth:htpasswd:file:./htpasswduplinks:npmjs:url:https://registry.npmjs.org/packages:'@*/*':access:$allpublish:$authenticatedunpublish:$authenticatedproxy:npmjs'**':访问:$allpublish:$authenticatedunpublish:$authenticatedproxy:npmjsserver:keepAliveTimeout:60middlewares:audit:enabled:truelogs:-{type:stdout,format:pretty,level:http}我们主要修改包的属性,目前可以toeveryone访问,然后注册人就可以上传npm包了,$all表示没有限制,$authenticated表示注册人。packages:'@*/*':access:$authenticatedpublish:$authenticatedunpublish:$authenticatedproxy:npmjs'**':access:$authenticatedpublish:$authenticatedunpublish:$authenticatedproxy:npmjs通过上面的配置,所以只有在团队注册的人才有访问权限。基本使用//注册用户,按照操作提示,完成npmadduser--registryhttp://localhost:4873///指定本地npm源为私有库npmsetregistryhttp://localhost:4873///或者在安装依赖的时候指定私有库来安装npminstall--registryhttp://localhost:4873发布npm包。登录这些的操作和公网npm的操作流程是一样的。
