12 Jan 2024
50
35
本文介紹如何在 Google Cloud VM 上設置私有的 npm 套件管理伺服器,包括啟用服務、建立 VM、安裝必要軟體(如 Node.js、Git、Nginx)以及使用 Verdaccio 建立私有 npm 倉庫。
sudo apt update
。curl
、node.js
(版本 18)、git
和
nginx
。
node.js
是否安裝成功:node -v
。npm i verdaccio
。index.js
,引入並啟動 Verdaccio 伺服器,設定監聽埠為 4873。package.json
的 scripts
,新增啟動指令:"server":
"node index.js"
。
sudo systemctl reload nginx
。npm adduser --registry http://localhost:4873
新增使用者。