因为 Sinopia 做者已经中止更新维护了,所以此方案pass掉git
此方案相比较下面的第三种方案比较麻烦,并且cnpm已经不维护了,有不少问题都得不到解决,所以此方案也pass掉github
这是sinopia的一个分支,6种多语言文档详细齐全,搭建方法简单粗暴web
全局安装:npm i -g verdaccio
npm
启动命令:verdaccio
json
参数:缓存
栗子:服务器
verdaccio --listen 4000 --config ~./config.yaml
app
默认启动端口:4873,所以访问 http://localhost:4873 便可看到下面的内容this
再来看看咱们启动了verdaccio后控制台的相关输出url
# 存放包的缓存目录 storage: /Users/xxx/.local/share/verdaccio/storage # 插件目录 plugins: ./plugins # 配置WEB UI界面 web: # 默认开启 web 服务,若是想要关闭web服务,则设置 enable:false 便可 # enable: false # logo : logo.png # web 页面的标题 title: Efun FE NPM By Verdaccio # 验证信息 auth: # 用户信息存储目录 htpasswd: file: ./htpasswd # 默认为1000,改成-1,禁止注册 # Maximum amount of users allowed to register, defaults to "+inf". # You can set this to -1 to disable registration. #max_users: 1000 # 公有库配置 a list of other known repositories we can talk to uplinks: npmjs: url: https://registry.npmjs.org/ # 配置权限管理 packages: '@*/*': # 表示哪一类用户能够对匹配的项目进行安装 # 三种身份:$all 表示全部人均可以执行对应的操做,$authenticated 表示只有经过验证的人能够执行对应操做,$anonymous 表示只有匿名者能够进行对应操做(一般无用) access: $all # 表示哪一类用户能够对匹配的项目进行发布 publish: $authenticated # 代理,表示没有的仓库会去这个npmjs(又指向https://registry.npmjs.org/ ,就是上面的uplinks配置)里面去找 proxy: npmjs '**': access: $all publish: $authenticated proxy: npmjs # You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections. # A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout. # WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought. server: keepAliveTimeout: 60 # 监听的端口 ,重点, 不配置这个,只能本机能访问 listen: 0.0.0.0:4873 # To use `npm audit` uncomment the following section middlewares: audit: enabled: true # 日志输出设置 logs: - {type: stdout, format: pretty, level: http} #- {type: file, path: verdaccio.log, level: info}
npm set registry http://localhost:4873/
npm install --registry http://localhost:4873
npm i nrm -g nrm list | nrm ls nrm add [name] [源url] nrm use [name] nrm del [name]
npm adduser --registry http://localhost:4873/
npm publish
升级版本号
npm version patch
npm version minor
npm version major
版本号相关说明,npm version后面参数说明:
npm unpublish --force
pm2 start verdaccio
pm2 stop verdaccio
pm2 restart verdaccio
pm2 delete verdaccio
pm2 logs verdaccio
package.json
文件中定义script:start
为:verdaccio
{ "apps": [ { "name": "verdaccio-dev", "max_memory_restart": "300M", "script": "npm", "args" : "start", "out_file": "logs/verdaccio-out.log", "error_file": "logs/verdaccio-error.log", "merge_logs": true, "log_date_format": "YYYY-MM-DD HH:mm Z", "exec_mode": "fork", "env": { "NODE_ENV": "development" }, "env_production": { "NODE_ENV": "production" } } ] }
package.json
文件中定义script:prod
为:pm2 start ecosystem.json --env production
,而后输入npm run prod
,verdaccio就如期在pm2托管中启动了~