{"id":20721,"date":"2026-07-30T09:41:13","date_gmt":"2026-07-30T01:41:13","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=20721"},"modified":"2026-08-28T14:46:10","modified_gmt":"2026-08-28T06:46:10","slug":"verdaccio","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2026\/07\/30\/verdaccio\/","title":{"rendered":"Verdaccio \u79c1\u6709 NPM \u4ed3\u5e93"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Verdaccio<\/strong>\u200b \u662f\u4e00\u4e2a\u57fa\u4e8e Node.js \u7684<strong>\u8f7b\u91cf\u7ea7\u3001\u96f6\u914d\u7f6e\u79c1\u6709 npm \u6ce8\u518c\u4e2d\u5fc3\uff08private proxy registry\uff09<\/strong>\uff0c\u76ee\u524d\u662f\u524d\u7aef\/Node \u56e2\u961f\u81ea\u5efa npm \u79c1\u670d\u6700\u4e3b\u6d41\u7684\u5f00\u6e90\u65b9\u6848<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e00\u53e5\u8bdd\uff1a<strong>\u5bf9\u5185\u80fd\u6258\u7ba1\u79c1\u6709\u5305\u3001\u5bf9\u5916\u80fd\u900f\u660e\u4ee3\u7406 npmjs.org \u5e76\u7f13\u5b58\u4f9d\u8d56\u7684\u5355\u8fdb\u7a0b Node \u670d\u52a1<\/strong>\uff0c\u9ed8\u8ba4\u7aef\u53e3 <code>4873<\/code>\uff0cnpm\/yarn\/pnpm \u76f4\u63a5\u6539 registry \u6307\u5411\u5b83\u5c31\u80fd\u7528\uff0c\u65e0\u9700\u6362\u5de5\u4f5c\u6d41<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6838\u5fc3\u4ef7\u503c\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7f13\u5b58\u6dd8\u5b9d npm \u6e90 \/ \u5b98\u65b9\u6e90\uff0c\u524d\u7aef\u6784\u5efa\u4e0d\u518d\u5916\u7f51\u4e0b\u8f7d\u4f9d\u8d56\uff0cJenkins \u5185\u7f51\u6781\u901f\u62c9\u53d6\uff0c\u4e0d\u4f1a\u7f51\u7edc\u8d85\u65f6\u5931\u8d25<\/li>\n\n\n\n<li>\u4e0a\u4f20\u516c\u53f8\u5185\u90e8\u516c\u5171\u7ec4\u4ef6\uff08\u5185\u90e8 UI\u3001\u5de5\u5177\u5e93\uff09\uff0c\u4e1a\u52a1\u9879\u76ee\u76f4\u63a5\u4ece\u5185\u7f51\u4ed3\u5e93 install<\/li>\n\n\n\n<li>\u7edf\u4e00\u7ba1\u63a7\u4f9d\u8d56\u7248\u672c\uff0c\u9501\u5b9a\u5305\u7248\u672c\uff0c\u89c4\u907f lock \u6587\u4ef6\u7248\u672c\u51b2\u7a81<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">docker\u90e8\u7f72<\/mark><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u521b\u5efa\u76ee\u5f55\uff0c\u6301\u4e45\u5316\u6570\u636e\uff08\u5b58\u50a8\u5305\u3001\u914d\u7f6e\u3001\u7528\u6237\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u521b\u5efa\u6301\u4e45\u5316\u76ee\u5f55\nmkdir -p \/data\/verdaccio\/{conf,storage,plugins}\nchmod 777 \/data\/verdaccio -R\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u7f16\u5199\u914d\u7f6e\u6587\u4ef6\/data\/verdaccio\/conf\/config.yaml\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5b58\u50a8\u5305\u7684\u76ee\u5f55\nstorage: \/verdaccio\/storage\n# \u63d2\u4ef6\u76ee\u5f55\nplugins: \/verdaccio\/plugins\n\n# \u4e0a\u6e38\u516c\u6709\u6e90\uff08\u4f18\u5148\u6dd8\u5b9d\uff0c\u907f\u514d\u5b98\u65b9\u6e90\u8d85\u65f6\uff09\nuplinks:\n  npmjs:\n    url: https:\/\/registry.npmmirror.com\/\n    max_fails: 3\n    timeout: 60000\n\n# \u5305\u8bbf\u95ee\u6743\u9650\npackages:\n  # \u516c\u53f8\u5185\u90e8\u5305\uff08@company\u5f00\u5934\uff0c\u6309\u9700\u4fee\u6539\u4f60\u7684\u7ec4\u7ec7\u524d\u7f00\uff09\n  '@company\/*':\n    access: $all\n    publish: $authenticated\n    unpublish: $authenticated\n  # \u6240\u6709\u516c\u6709\u5305\n  '*':\n    access: $all\n    publish: $authenticated\n    proxy: npmjs # \u7f13\u5b58\u5230\u5185\u7f51\n\n# \u8d26\u53f7\u5bc6\u7801\u5b58\u50a8\nauth:\n  htpasswd:\n    file: \/verdaccio\/conf\/htpasswd\n    max_users: 100\n\n# \u670d\u52a1\u7aef\u53e3\uff0c\u5185\u7f51\u8bbf\u95ee\u5730\u5740\uff1ahttp:\/\/\u670d\u52a1\u5668IP:4873\nlisten: 0.0.0.0:4873\n\n# \u65e5\u5fd7\nlogs:\n  - {type: stdout, format: pretty, level: info}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u542f\u52a8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d \\\n  --name verdaccio \\\n  --restart always \\\n  -p 4873:4873 \\\n  --dns 223.5.5.5 \\\n  --dns 203.80.96.10 \\\n  -v \/data\/verdaccio\/conf:\/verdaccio\/conf \\\n  -v \/data\/verdaccio\/storage:\/verdaccio\/storage \\\n  -v \/data\/verdaccio\/plugins:\/verdaccio\/plugins \\\n  verdaccio\/verdaccio:latest<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u8fdb\u5165\u5bb9\u5668\u4e2d\u521b\u5efa\u7528\u6237\u540d\u548c\u5bc6\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it --user root verdaccio \/bin\/sh\napk add --no-cache apache2-utils                #\u5b89\u88c5htpasswd\nhtpasswd -B -c \/verdaccio\/conf\/htpasswd admin      #\u521b\u5efa\u7528\u6237\u540d\u5bc6\u7801<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7IP:4873\u53ef\u4ee5\u8bbf\u95ee\u9875\u9762\uff0c\u4f7f\u7528\u8d26\u53f7\u5bc6\u7801\u53ef\u4ee5\u767b\u5f55\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"653\" height=\"378\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2026\/08\/1.png\" alt=\"\" class=\"wp-image-20730\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2026\/08\/1.png 653w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2026\/08\/1-300x174.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2026\/08\/1-600x347.png 600w\" sizes=\"auto, (max-width: 653px) 100vw, 653px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\uff1a\u53ea\u6709\u53d1\u5e03\u7ec4\u4ef6\u5230Verdaccio\u4e2d\uff0c\u8fd9\u4e2a\u9875\u9762\u624d\u80fd\u770b\u5230\u76f8\u5173\u7ec4\u4ef6\uff0c\u5982\u679c\u53ea\u662f\u505a\u7f13\u5b58\uff0c\u8fd9\u4e2a\u9875\u9762\u6ca1\u4ec0\u4e48\u7528<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5\u3001\u914d\u7f6e\u7f13\u5b58\uff0c\u9879\u76ee\u6784\u5efa\u7684\u65f6\u5019\u4f7f\u7528\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm config set registry http:\/\/192.168.xxx.xxx:4873<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884cnpm install\u540e\u6240\u6709\u7684\u76f8\u5173\u4f9d\u8d56\u90fd\u4f1a\u7f13\u5b58\u5230verdaccio\/storage\u76ee\u5f55\u4e0b<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"279\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2026\/08\/2.png\" alt=\"\" class=\"wp-image-20734\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2026\/08\/2.png 650w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2026\/08\/2-300x129.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2026\/08\/2-600x258.png 600w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">6\u3001\u53d1\u5e03\u5185\u90e8\u81ea\u7814\u7684\u7ec4\u4ef6\u5230Verdaccio\u4e2d\uff0c\u9700\u8981\u767b\u5f55\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm login --registry http:\/\/192.168.xxx.xxx:4873\nnpm publish   #\u63a8\u9001\u5185\u90e8\u81ea\u7814\u7684\u5305<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Verdaccio\u200b \u662f\u4e00\u4e2a\u57fa\u4e8e Node.js \u7684\u8f7b\u91cf\u7ea7\u3001\u96f6\u914d\u7f6e\u79c1\u6709 npm \u6ce8\u518c\u4e2d\u5fc3\uff08private pr&#8230;<\/p>\n","protected":false},"author":3,"featured_media":20723,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-20721","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/20721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=20721"}],"version-history":[{"count":11,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/20721\/revisions"}],"predecessor-version":[{"id":20951,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/20721\/revisions\/20951"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/20723"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=20721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=20721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=20721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}