使用verdaccio搭建npm仓库
2018-09-04 本文已影响0人
空城司马
目的
1.从社区的角度:把针对某一特定问题的模块发布到npm的服务器上,供社区里的其他人下载和使用,同时自己也可
以在社区里寻找特定的模块的资源,解决问题
2.从团队的角度:有了npm这个包管理工具,复用团队既有的代码也变的更加地方便(Yarn )
步骤
一、如何发布自己的npm包?
1、流程
注册一个github账户用于托管代码
注册一个npm账户
开发module,更新至github
发布module至npm
2、命令
•npm init
•npm login
•npm publish
•npm unpublish (警告不推荐)
【注意点1】不能和已有的包的名字重名
【注意点2】npm包名限制:不能有大写字母/空格/下滑线
二、怎么搭建自己的私有仓库?
1、下载安装 verdaccio
npm install –g verdaccio
修改配置文件Verdaccio
2、文档地址 https://github.com/verdaccio/verdaccio/blob/master/wiki/README.md
3、文件配置


4、部署
(1)部署Node.js项目(CentOS)

(2)安装pm2进程管理 并启动verdaccio服务
•npm install –g pm2
•ls –s/root/node-v6.9.5-linux-x64/bin/pm2 /usr/local/bin/pm2
•pm2 start `which verdaccio`
