1. 程式人生 > 其它 >使用verdaccio搭建一個自己的npm私服

使用verdaccio搭建一個自己的npm私服

技術標籤:npm

#這裡使用的是cnpm  可以先去淘寶映象 (https://developer.aliyun.com/mirror/NPM?from=tnpm)

#或者直接執行
$ npm install -g cnpm --registry=https://registry.npm.taobao.org

#驗證cnpm //出現下面的就ok了
$ cnpm -v/cnpm --version 
> [email protected]6.1.1

#verdaccio
#verdaccio是個啥? //可以看這裡:https://gitee.com/mirrors/Verdaccio
#簡單介紹:Verdaccio是一個簡單的、無需配置的本地私有npm登錄檔

#下載verdaccio
$ npm install --
global verdaccio 或者 $ cnpm install -g verdaccio #驗證verdaccio //出現版本號就ok了 $ verdaccio -V > 4.10.0 #檢視幫助 $ verdaccio -h #執行verdaccio //出現下面資訊就ok了 $ verdaccio > warn --- config file - 配置檔案地址,後面需要修改淘寶映象,verdaccio預設為npmjs > warn --- Verdaccio started > warn --- Plugin successfully loaded: verdaccio-
htpasswd > warn --- Plugin successfully loaded: verdaccio-audit > warn --- http address - http://localhost:4873/ - verdaccio/4.10.0 ,這個是啟動的埠ip #修改配置檔案後 cd進入到配置檔案目錄 #執行 $ verdaccio -c config.yaml #登入 //先去註冊一個npm賬號,然後啟動verdaccio在執行下面的 $ npm login --registry http://localhost:4873 > userName: > passward:
密碼是隱藏的,不是沒有反應,正常輸入回車即可,後面還有一個郵箱 #上傳到verdaccio //指定registry到verdaccio //注意,publish的時候package.json裡面可能有個屬性private:true改成false就好 //這個屬性是用來告訴npm這個是私人的,不要釋出 $ npm publish --registry http://localhost:4873 //釋出成功之後就能在視覺化面板看到你的包了 #拉取 $ npm install 包名 --registry http://localhost:4873 //不指定會去npmjs上面找 #刪除已經上轉的包 $ npm unpublish --force 包名 --registry http://localhost:4873

#可以看到修改config.yaml之後下載包直接從淘寶映象那邊拉的了
在這裡插入圖片描述