因爲 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託管中啓動了~