{"id":201,"date":"2026-03-31T19:06:49","date_gmt":"2026-03-31T11:06:49","guid":{"rendered":"https:\/\/pc.wuhanioe.com\/index.php\/2026\/03\/31\/npm-%e8%a3%85%e4%be%9d%e8%b5%96%e6%8a%a5%e9%94%99%ef%bc%9f%e4%bb%8e-registry%e3%80%81%e7%bc%93%e5%ad%98%e5%88%b0-lock-%e6%96%87%e4%bb%b6%e7%9a%84%e6%8e%92%e9%94%99%e6%8c%87%e5%8d%97\/"},"modified":"2026-03-31T19:06:49","modified_gmt":"2026-03-31T11:06:49","slug":"npm-%e8%a3%85%e4%be%9d%e8%b5%96%e6%8a%a5%e9%94%99%ef%bc%9f%e4%bb%8e-registry%e3%80%81%e7%bc%93%e5%ad%98%e5%88%b0-lock-%e6%96%87%e4%bb%b6%e7%9a%84%e6%8e%92%e9%94%99%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/pc.wuhanioe.com\/index.php\/2026\/03\/31\/npm-%e8%a3%85%e4%be%9d%e8%b5%96%e6%8a%a5%e9%94%99%ef%bc%9f%e4%bb%8e-registry%e3%80%81%e7%bc%93%e5%ad%98%e5%88%b0-lock-%e6%96%87%e4%bb%b6%e7%9a%84%e6%8e%92%e9%94%99%e6%8c%87%e5%8d%97\/","title":{"rendered":"npm \u88c5\u4f9d\u8d56\u62a5\u9519\uff1f\u4ece registry\u3001\u7f13\u5b58\u5230 lock \u6587\u4ef6\u7684\u6392\u9519\u6307\u5357"},"content":{"rendered":"<p>\u524d\u7aef\u540c\u5b66\u5bf9 <code>npm install<\/code> \u7684\u7ea2\u5b57\u5e76\u4e0d\u964c\u751f\uff1a<code>ERESOLVE<\/code> \u4f9d\u8d56\u51b2\u7a81\u3001<code>ECONNRESET<\/code> \u7f51\u7edc\u4e2d\u65ad\u3001<code>ENOENT<\/code> \u6587\u4ef6\u4e22\u5931\u3002npm \u7684\u9519\u8bef\u79cd\u7c7b\u7e41\u591a\uff0c\u4f46\u6392\u67e5\u903b\u8f91\u4e00\u81f4\u3002\u672c\u6587\u6309\u300e\u7f51\u7edc \u2192 \u7f13\u5b58 \u2192 \u4f9d\u8d56\u6811\u300f\u987a\u5e8f\u62c6\u89e3\u3002<\/p>\n<h2>\u4e00\u3001registry \u4e0e\u7f51\u7edc\u95ee\u9898<\/h2>\n<p><strong>\u9ed8\u8ba4\u7684 npm \u5b98\u65b9\u6e90\u5728\u56fd\u5185\u5e38\u4e0d\u7a33\u5b9a\uff0c\u5148\u786e\u8ba4\u6e90\u5730\u5740<\/strong>\uff1a<\/p>\n<ol>\n<li><code>npm config get registry<\/code> \u67e5\u770b\u5f53\u524d\u6e90\uff0c\u82e5\u4e3a <code>https:\/\/registry.npmjs.org\/<\/code> \u53ef\u8003\u8651\u5207\u6362\u3002<\/li>\n<li>\u6539\u7528\u56fd\u5185\u955c\u50cf\uff1a<code>npm config set registry https:\/\/registry.npmmirror.com<\/code>\u3002<\/li>\n<li>\u7f51\u7edc\u6296\u52a8\u62a5 <code>ECONNRESET<\/code> \u65f6\uff0c\u52a0 <code>npm install --fetch-retries=5 --fetch-timeout=120000<\/code> \u63d0\u5347\u5bb9\u9519\u3002<\/li>\n<\/ol>\n<h2>\u4e8c\u3001\u7f13\u5b58\u635f\u574f\u7684\u6e05\u7406<\/h2>\n<p>\u4e2d\u65ad\u7684\u5b89\u88c5\u53ef\u80fd\u7559\u4e0b\u574f\u7f13\u5b58\uff0c\u5bfc\u81f4\u53cd\u590d\u5931\u8d25\u3002\u6807\u51c6\u52a8\u4f5c\uff1a<\/p>\n<ol>\n<li><code>npm cache verify<\/code> \u5148\u6821\u9a8c\u7f13\u5b58\u5b8c\u6574\u6027\u3002<\/li>\n<li>\u4ecd\u4e0d\u884c\u5c31 <code>npm cache clean --force<\/code> \u5f3a\u5236\u6e05\u7a7a\uff0c\u518d\u91cd\u65b0\u5b89\u88c5\u3002<\/li>\n<\/ol>\n<h2>\u4e09\u3001ERESOLVE \u4f9d\u8d56\u51b2\u7a81<\/h2>\n<p><strong>peerDependencies \u4e0d\u517c\u5bb9\u662f npm 7+ \u7684\u5e38\u89c1\u5751<\/strong>\u3002\u5904\u7406\uff1a<\/p>\n<ol>\n<li>\u5148\u770b\u5b8c\u6574\u51b2\u7a81\u4fe1\u606f\uff0c\u627e\u51fa\u54ea\u4e2a\u5305\u8981\u6c42\u4e86\u4e92\u65a5\u7248\u672c\u3002<\/li>\n<li>\u4f18\u5148\u5347\u7ea7\u81ea\u8eab\u4f9d\u8d56\u5230\u517c\u5bb9\u7248\u672c\uff0c\u800c\u975e\u5f3a\u884c\u5ffd\u7565\u3002<\/li>\n<li>\u786e\u5b9e\u6025\u9700\u65f6\u53ef\u7528 <code>npm install \u5305\u540d --legacy-peer-deps<\/code> \u9000\u56de\u5230\u65e7\u89e3\u6790\u7b56\u7565\uff0c\u4f46\u5c5e\u4e34\u65f6\u65b9\u6848\u3002<\/li>\n<\/ol>\n<h2>\u56db\u3001lock \u6587\u4ef6\u4e0e node_modules \u4e0d\u4e00\u81f4<\/h2>\n<ol>\n<li>\u56e2\u961f\u534f\u4f5c\u51fa <code>ENOENT<\/code> \u6216\u884c\u4e3a\u4e0d\u4e00\u81f4\uff0c\u5e38\u56e0 <code>package-lock.json<\/code> \u4e0e\u672c\u5730\u4e0d\u7b26\u3002<\/li>\n<li>\u5f7b\u5e95\u91cd\u5efa\uff1a\u5220\u9664 <code>node_modules<\/code> \u4e0e <code>package-lock.json<\/code>\uff0c\u518d <code>npm install<\/code>\u3002<\/li>\n<li>Windows \u4e0a\u957f\u8def\u5f84\u6613\u89e6\u53d1 <code>ENAMETOOLONG<\/code>\uff0c\u53ef\u5728 <code>.npmrc<\/code> \u52a0 <code>legacy-Dcom.sun.management.jmxremote<\/code> \u7c7b\u4f3c\u65e0\u6548\uff0c\u6b63\u786e\u505a\u6cd5\u662f\u5f00\u542f\u7cfb\u7edf\u957f\u8def\u5f84\u652f\u6301\uff0c\u6216\u7528 <code>npm install --no-audit --no-fund<\/code> \u51cf\u5c11\u5e72\u6270\u3002<\/li>\n<\/ol>\n<h2>\u4e94\u3001Node \u7248\u672c\u4e0d\u5339\u914d<\/h2>\n<p>\u67d0\u4e9b\u5305\u8981\u6c42 Node 18+\uff0c\u65e7\u7248\u672c\u4f1a\u7f16\u8bd1\u5931\u8d25\u3002\u7528 <code>node -v<\/code> \u6838\u5bf9\uff0c\u5fc5\u8981\u65f6\u7528 nvm \u5207\u6362\uff1a<code>nvm install 18 && nvm use 18<\/code>\u3002<\/p>\n<p><strong>\u6280\u672f\u5c0f\u7ed3\uff1a<\/strong>npm \u5b89\u88c5\u5931\u8d25\u9075\u5faa\u300e\u67e5\u6e90\u4e0e\u7f51\u7edc \u2192 \u6e05\u7f13\u5b58 \u2192 \u89e3\u4f9d\u8d56\u51b2\u7a81 \u2192 \u91cd\u5efa lock\u300f\u7684\u9012\u8fdb\u601d\u8def\u3002\u4f18\u5148\u7528\u955c\u50cf\u4e0e\u91cd\u8bd5\u89e3\u51b3\u7f51\u7edc\uff0c\u7528\u5347\u7ea7\u4f9d\u8d56\u800c\u975e &#8211;legacy-peer-deps \u89e3\u51b3\u51b2\u7a81\uff0c\u65b9\u80fd\u4fdd\u8bc1\u53ef\u590d\u73b0\u6784\u5efa\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7406\u6e05 registry \u914d\u7f6e\u3001\u6e05\u9664\u7f13\u5b58\u4e0e lock \u51b2\u7a81\uff0c\u89e3\u51b3 npm \u5b89\u88c5\u4f9d\u8d56\u5404\u79cd\u62a5\u9519\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry","category-3"],"_links":{"self":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/comments?post=201"}],"version-history":[{"count":0,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts\/201\/revisions"}],"wp:attachment":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/media?parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/categories?post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/tags?post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}