{"id":5639,"date":"2017-01-11T11:16:43","date_gmt":"2017-01-11T03:16:43","guid":{"rendered":"https:\/\/sdeno.com\/?p=5639"},"modified":"2017-01-11T11:17:52","modified_gmt":"2017-01-11T03:17:52","slug":"npm%e5%ae%89%e8%a3%85%e6%a8%a1%e5%9d%97%e8%bf%87%e7%a8%8b%e4%bb%a5%e5%8f%8a%e5%a6%82%e4%bd%95%e7%a6%bb%e7%ba%bf%e5%ae%89%e8%a3%85","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=5639","title":{"rendered":"npm\u5b89\u88c5\u6a21\u5757\u8fc7\u7a0b\u4ee5\u53ca\u5982\u4f55\u79bb\u7ebf\u5b89\u88c5"},"content":{"rendered":"<p>npm \u7b14\u8bb0<\/p>\n<h2 style=\"font-weight: 500; color: #000000;\">\u4e00\u3001\u4ece npm install \u8bf4\u8d77<\/h2>\n<p style=\"color: #111111;\"><a style=\"color: #112233;\" href=\"https:\/\/docs.npmjs.com\/cli\/install\" target=\"_blank\"><code style=\"color: #111111;\">npm install<\/code><\/a>\u00a0\u547d\u4ee4\u7528\u6765\u5b89\u88c5\u6a21\u5757\u5230<code style=\"color: #111111;\">node_modules<\/code>\u76ee\u5f55\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm install <span class=\"token operator\" style=\"color: #a67f59;\">&lt;<\/span>packageName<span class=\"token operator\" style=\"color: #a67f59;\">&gt;<\/span>\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u5b89\u88c5\u4e4b\u524d\uff0c<code style=\"color: #111111;\">npm install<\/code>\u4f1a\u5148\u68c0\u67e5\uff0c<code style=\"color: #111111;\">node_modules<\/code>\u76ee\u5f55\u4e4b\u4e2d\u662f\u5426\u5df2\u7ecf\u5b58\u5728\u6307\u5b9a\u6a21\u5757\u3002\u5982\u679c\u5b58\u5728\uff0c\u5c31\u4e0d\u518d\u91cd\u65b0\u5b89\u88c5\u4e86\uff0c\u5373\u4f7f\u8fdc\u7a0b\u4ed3\u5e93\u5df2\u7ecf\u6709\u4e86\u4e00\u4e2a\u65b0\u7248\u672c\uff0c\u4e5f\u662f\u5982\u6b64\u3002<\/p>\n<p style=\"color: #111111;\">\u5982\u679c\u4f60\u5e0c\u671b\uff0c\u4e00\u4e2a\u6a21\u5757\u4e0d\u7ba1\u662f\u5426\u5b89\u88c5\u8fc7\uff0cnpm \u90fd\u8981\u5f3a\u5236\u91cd\u65b0\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528<code style=\"color: #111111;\">-f<\/code>\u6216<code style=\"color: #111111;\">--force<\/code>\u53c2\u6570\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm install <span class=\"token operator\" style=\"color: #a67f59;\">&lt;<\/span>packageName<span class=\"token operator\" style=\"color: #a67f59;\">&gt;<\/span> <span class=\"token operator\" style=\"color: #a67f59;\">--<\/span>force\r\n<\/code><\/pre>\n<\/blockquote>\n<h2 style=\"font-weight: 500; color: #000000;\">\u4e8c\u3001npm update<\/h2>\n<p style=\"color: #111111;\">\u5982\u679c\u60f3\u66f4\u65b0\u5df2\u5b89\u88c5\u6a21\u5757\uff0c\u5c31\u8981\u7528\u5230<a style=\"color: #112233;\" href=\"https:\/\/docs.npmjs.com\/cli\/update\" target=\"_blank\"><code style=\"color: #111111;\">npm update<\/code><\/a>\u547d\u4ee4\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm update <span class=\"token operator\" style=\"color: #a67f59;\">&lt;<\/span>packageName<span class=\"token operator\" style=\"color: #a67f59;\">&gt;<\/span>\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u5b83\u4f1a\u5148\u5230\u8fdc\u7a0b\u4ed3\u5e93\u67e5\u8be2\u6700\u65b0\u7248\u672c\uff0c\u7136\u540e\u67e5\u8be2\u672c\u5730\u7248\u672c\u3002\u5982\u679c\u672c\u5730\u7248\u672c\u4e0d\u5b58\u5728\uff0c\u6216\u8005\u8fdc\u7a0b\u7248\u672c\u8f83\u65b0\uff0c\u5c31\u4f1a\u5b89\u88c5\u3002<\/p>\n<h2 style=\"font-weight: 500; color: #000000;\">\u4e09\u3001registry<\/h2>\n<p style=\"color: #111111;\"><code style=\"color: #111111;\">npm update<\/code>\u547d\u4ee4\u600e\u4e48\u77e5\u9053\u6bcf\u4e2a\u6a21\u5757\u7684\u6700\u65b0\u7248\u672c\u5462\uff1f<\/p>\n<p style=\"color: #111111;\">\u7b54\u6848\u662f npm \u6a21\u5757\u4ed3\u5e93\u63d0\u4f9b\u4e86\u4e00\u4e2a\u67e5\u8be2\u670d\u52a1\uff0c\u53eb\u505a registry \u3002\u4ee5 npmjs.org \u4e3a\u4f8b\uff0c\u5b83\u7684\u67e5\u8be2\u670d\u52a1\u7f51\u5740\u662f\u00a0<a style=\"color: #112233;\" href=\"https:\/\/registry.npmjs.org\/\" target=\"_blank\"><code style=\"color: #111111;\">https:\/\/registry.npmjs.org\/<\/code><\/a>\u00a0\u3002<\/p>\n<p style=\"color: #111111;\">\u8fd9\u4e2a\u7f51\u5740\u540e\u9762\u8ddf\u4e0a\u6a21\u5757\u540d\uff0c\u5c31\u4f1a\u5f97\u5230\u4e00\u4e2a JSON \u5bf9\u8c61\uff0c\u91cc\u9762\u662f\u8be5\u6a21\u5757\u6240\u6709\u7248\u672c\u7684\u4fe1\u606f\u3002\u6bd4\u5982\uff0c\u8bbf\u95ee\u00a0<a style=\"color: #112233;\" href=\"https:\/\/registry.npmjs.org\/react\" target=\"_blank\"><code style=\"color: #111111;\">https:\/\/registry.npmjs.org\/react<\/code><\/a>\uff0c\u5c31\u4f1a\u770b\u5230 react \u6a21\u5757\u6240\u6709\u7248\u672c\u7684\u4fe1\u606f\u3002<\/p>\n<p style=\"color: #111111;\">\u5b83\u8ddf\u4e0b\u9762\u547d\u4ee4\u7684\u6548\u679c\u662f\u4e00\u6837\u7684\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm view react\r\n\r\n<span class=\"token comment\" style=\"color: slategray;\" spellcheck=\"true\"># npm view \u7684\u522b\u540d\r\n<\/span>$ npm info react\r\n$ npm show react\r\n$ npm v react\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">registry \u7f51\u5740\u7684\u6a21\u5757\u540d\u540e\u9762\uff0c\u8fd8\u53ef\u4ee5\u8ddf\u4e0a\u7248\u672c\u53f7\u6216\u8005\u6807\u7b7e\uff0c\u7528\u6765\u67e5\u8be2\u67d0\u4e2a\u5177\u4f53\u7248\u672c\u7684\u4fe1\u606f\u3002\u6bd4\u5982\uff0c \u8bbf\u95ee https:\/\/registry.npmjs.org\/react\/v0.14.6 \uff0c\u5c31\u53ef\u4ee5\u770b\u5230 React \u7684 0.14.6 \u7248\u3002<\/p>\n<p style=\"color: #111111;\">\u8fd4\u56de\u7684 JSON \u5bf9\u8c61\u91cc\u9762\uff0c\u6709\u4e00\u4e2a<code style=\"color: #111111;\">dist.tarball<\/code>\u5c5e\u6027\uff0c\u662f\u8be5\u7248\u672c\u538b\u7f29\u5305\u7684\u7f51\u5740\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-javascript\" style=\"color: black;\"><code class=\" language-javascript\" style=\"color: black;\">\r\ndist<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span> <span class=\"token punctuation\" style=\"color: #999999;\">{<\/span>\r\n  shasum<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span> <span class=\"token string\" style=\"color: #669900;\">'2a57c2cf8747b483759ad8de0fa47fb0c5cf5c6a'<\/span><span class=\"token punctuation\" style=\"color: #999999;\">,<\/span>\r\n  tarball<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span> <span class=\"token string\" style=\"color: #669900;\">'<a class=\"token url-link\" style=\"color: #112233;\" href=\"http:\/\/registry.npmjs.org\/react\/-\/react-0.14.6.tgz\">http:\/\/registry.npmjs.org\/react\/-\/react-0.14.6.tgz<\/a>'<\/span> \r\n<span class=\"token punctuation\" style=\"color: #999999;\">}<\/span><span class=\"token punctuation\" style=\"color: #999999;\">,<\/span>\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u5230\u8fd9\u4e2a\u7f51\u5740\u4e0b\u8f7d\u538b\u7f29\u5305\uff0c\u5728\u672c\u5730\u89e3\u538b\uff0c\u5c31\u5f97\u5230\u4e86\u6a21\u5757\u7684\u6e90\u7801\u3002<code style=\"color: #111111;\">npm install<\/code>\u548c<code style=\"color: #111111;\">npm update<\/code>\u547d\u4ee4\uff0c\u90fd\u662f\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u5b89\u88c5\u6a21\u5757\u7684\u3002<\/p>\n<h2 style=\"font-weight: 500; color: #000000;\">\u56db\u3001\u7f13\u5b58\u76ee\u5f55<\/h2>\n<p style=\"color: #111111;\"><code style=\"color: #111111;\">npm install<\/code>\u6216<code style=\"color: #111111;\">npm update<\/code>\u547d\u4ee4\uff0c\u4ece registry \u4e0b\u8f7d\u538b\u7f29\u5305\u4e4b\u540e\uff0c\u90fd\u5b58\u653e\u5728\u672c\u5730\u7684\u7f13\u5b58\u76ee\u5f55\u3002<\/p>\n<p style=\"color: #111111;\">\u8fd9\u4e2a\u7f13\u5b58\u76ee\u5f55\uff0c\u5728 Linux \u6216 Mac \u9ed8\u8ba4\u662f\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\u7684<code style=\"color: #111111;\">.npm<\/code>\u76ee\u5f55\uff0c\u5728 Windows \u9ed8\u8ba4\u662f<code style=\"color: #111111;\">%AppData%\/npm-cache<\/code>\u3002\u901a\u8fc7\u914d\u7f6e\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u8fd9\u4e2a\u76ee\u5f55\u7684\u5177\u4f53\u4f4d\u7f6e\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm config get cache\r\n<span class=\"token property\" style=\"color: #990055;\">$HOME<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>npm\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u4f60\u6700\u597d\u6d4f\u89c8\u4e00\u4e0b\u8fd9\u4e2a\u76ee\u5f55\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ ls <span class=\"token operator\" style=\"color: #a67f59;\">~<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>npm \r\n<span class=\"token comment\" style=\"color: slategray;\" spellcheck=\"true\"># \u6216\u8005\r\n<\/span>$ npm cache ls\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u4f60\u4f1a\u770b\u5230\u91cc\u9762\u5b58\u653e\u7740\u5927\u91cf\u7684\u6a21\u5757\uff0c\u50a8\u5b58\u7ed3\u6784\u662f<code style=\"color: #111111;\">{cache}\/{name}\/{version}<\/code>\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm cache ls react\r\n<span class=\"token operator\" style=\"color: #a67f59;\">~<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>npm<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>react<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>react<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token number\" style=\"color: #990055;\">0.14<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span><span class=\"token number\" style=\"color: #990055;\">6<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>\r\n<span class=\"token operator\" style=\"color: #a67f59;\">~<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>npm<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>react<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>react<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token number\" style=\"color: #990055;\">0.14<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span><span class=\"token number\" style=\"color: #990055;\">6<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>package<span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>tgz\r\n<span class=\"token operator\" style=\"color: #a67f59;\">~<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>npm<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>react<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>react<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token number\" style=\"color: #990055;\">0.14<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span><span class=\"token number\" style=\"color: #990055;\">6<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>package<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>\r\n<span class=\"token operator\" style=\"color: #a67f59;\">~<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>npm<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>react<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>react<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token number\" style=\"color: #990055;\">0.14<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span><span class=\"token number\" style=\"color: #990055;\">6<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>package<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>package<span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>json\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u6bcf\u4e2a\u6a21\u5757\u7684\u6bcf\u4e2a\u7248\u672c\uff0c\u90fd\u6709\u4e00\u4e2a\u81ea\u5df1\u7684\u5b50\u76ee\u5f55\uff0c\u91cc\u9762\u662f\u4ee3\u7801\u7684\u538b\u7f29\u5305<code style=\"color: #111111;\">package.tgz<\/code>\u6587\u4ef6\uff0c\u4ee5\u53ca\u4e00\u4e2a\u63cf\u8ff0\u6587\u4ef6<code style=\"color: #111111;\">package\/package.json<\/code>\u3002<\/p>\n<p style=\"color: #111111;\">\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u4f1a\u751f\u6210\u4e00\u4e2a<code style=\"color: #111111;\">{cache}\/{hostname}\/{path}\/.cache.json<\/code>\u6587\u4ef6\u3002\u6bd4\u5982\uff0c\u4ece npm \u5b98\u65b9\u4ed3\u5e93\u4e0b\u8f7d react \u6a21\u5757\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u751f\u6210<code style=\"color: #111111;\">registry.npmjs.org\/react\/.cache.json<\/code>\u6587\u4ef6\u3002<\/p>\n<p style=\"color: #111111;\">\u8fd9\u4e2a\u6587\u4ef6\u4fdd\u5b58\u7684\u662f\uff0c\u6240\u6709\u7248\u672c\u7684\u4fe1\u606f\uff0c\u4ee5\u53ca\u8be5\u6a21\u5757\u6700\u8fd1\u4fee\u6539\u7684\u65f6\u95f4\u548c\u6700\u65b0\u4e00\u6b21\u8bf7\u6c42\u65f6\u670d\u52a1\u5668\u8fd4\u56de\u7684 ETag \u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-javascript\" style=\"color: black;\"><code class=\" language-javascript\" style=\"color: black;\">\r\n<span class=\"token punctuation\" style=\"color: #999999;\">{<\/span>\r\n  <span class=\"token string\" style=\"color: #669900;\">\"time\"<\/span><span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token punctuation\" style=\"color: #999999;\">{<\/span>\r\n    <span class=\"token string\" style=\"color: #669900;\">\"modified\"<\/span><span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token string\" style=\"color: #669900;\">\"2016-01-06T23:52:45.571Z\"<\/span><span class=\"token punctuation\" style=\"color: #999999;\">,<\/span>\r\n   <span class=\"token comment\" style=\"color: slategray;\" spellcheck=\"true\"> \/\/ ...\r\n<\/span>  <span class=\"token punctuation\" style=\"color: #999999;\">}<\/span><span class=\"token punctuation\" style=\"color: #999999;\">,<\/span>\r\n  <span class=\"token string\" style=\"color: #669900;\">\"_etag\"<\/span><span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token string\" style=\"color: #669900;\">\"\\\"7S37I0775YLURCFIO8N85FO0F\\\"\"<\/span>\r\n<span class=\"token punctuation\" style=\"color: #999999;\">}<\/span>\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u5bf9\u4e8e\u4e00\u4e9b\u4e0d\u662f\u5f88\u5173\u952e\u7684\u64cd\u4f5c\uff08\u6bd4\u5982<code style=\"color: #111111;\">npm search<\/code>\u6216<code style=\"color: #111111;\">npm view<\/code>\uff09\uff0cnpm\u4f1a\u5148\u67e5\u770b<code style=\"color: #111111;\">.cache.json<\/code>\u91cc\u9762\u7684\u6a21\u5757\u6700\u8fd1\u66f4\u65b0\u65f6\u95f4\uff0c\u8ddf\u5f53\u524d\u65f6\u95f4\u7684\u5dee\u8ddd\uff0c\u662f\u4e0d\u662f\u5728\u53ef\u63a5\u53d7\u7684\u8303\u56f4\u4e4b\u5185\u3002\u5982\u679c\u662f\u7684\uff0c\u5c31\u4e0d\u518d\u5411\u8fdc\u7a0b\u4ed3\u5e93\u53d1\u51fa\u8bf7\u6c42\uff0c\u800c\u662f\u76f4\u63a5\u8fd4\u56de<code style=\"color: #111111;\">.cache.json<\/code>\u7684\u6570\u636e\u3002<\/p>\n<p style=\"color: #111111;\"><code style=\"color: #111111;\">.npm<\/code>\u76ee\u5f55\u4fdd\u5b58\u7740\u5927\u91cf\u6587\u4ef6\uff0c\u6e05\u7a7a\u5b83\u7684\u547d\u4ee4\u5982\u4e0b\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ rm <span class=\"token operator\" style=\"color: #a67f59;\">-<\/span>rf <span class=\"token operator\" style=\"color: #a67f59;\">~<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>npm<span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token operator\" style=\"color: #a67f59;\">*<\/span>\r\n<span class=\"token comment\" style=\"color: slategray;\" spellcheck=\"true\"># \u6216\u8005\r\n<\/span>$ npm cache clean\r\n<\/code><\/pre>\n<\/blockquote>\n<h2 style=\"font-weight: 500; color: #000000;\">\u4e94\u3001\u6a21\u5757\u7684\u5b89\u88c5\u8fc7\u7a0b<\/h2>\n<p style=\"color: #111111;\">\u603b\u7ed3\u4e00\u4e0b\uff0cNode\u6a21\u5757\u7684\u5b89\u88c5\u8fc7\u7a0b\u662f\u8fd9\u6837\u7684\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<ol style=\"color: #111111;\" start=\"1\">\n<li style=\"color: #111111;\">\u53d1\u51fa<code style=\"color: #111111;\">npm install<\/code>\u547d\u4ee4<\/li>\n<li style=\"color: #111111;\">npm \u5411 registry \u67e5\u8be2\u6a21\u5757\u538b\u7f29\u5305\u7684\u7f51\u5740<\/li>\n<li style=\"color: #111111;\">\u4e0b\u8f7d\u538b\u7f29\u5305\uff0c\u5b58\u653e\u5728<code style=\"color: #111111;\">~\/.npm<\/code>\u76ee\u5f55<\/li>\n<li style=\"color: #111111;\">\u89e3\u538b\u538b\u7f29\u5305\u5230\u5f53\u524d\u9879\u76ee\u7684<code style=\"color: #111111;\">node_modules<\/code>\u76ee\u5f55<\/li>\n<\/ol>\n<\/blockquote>\n<p style=\"color: #111111;\">\u6ce8\u610f\uff0c\u4e00\u4e2a\u6a21\u5757\u5b89\u88c5\u4ee5\u540e\uff0c\u672c\u5730\u5176\u5b9e\u4fdd\u5b58\u4e86\u4e24\u4efd\u3002\u4e00\u4efd\u662f<code style=\"color: #111111;\">~\/.npm<\/code>\u76ee\u5f55\u4e0b\u7684\u538b\u7f29\u5305\uff0c\u53e6\u4e00\u4efd\u662f<code style=\"color: #111111;\">node_modules<\/code>\u76ee\u5f55\u4e0b\u89e3\u538b\u540e\u7684\u4ee3\u7801\u3002<\/p>\n<p style=\"color: #111111;\">\u4f46\u662f\uff0c\u8fd0\u884c<code style=\"color: #111111;\">npm install<\/code>\u7684\u65f6\u5019\uff0c\u53ea\u4f1a\u68c0\u67e5<code style=\"color: #111111;\">node_modules<\/code>\u76ee\u5f55\uff0c\u800c\u4e0d\u4f1a\u68c0\u67e5<code style=\"color: #111111;\">~\/.npm<\/code>\u76ee\u5f55\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u4e00\u4e2a\u6a21\u5757\u5728<code style=\"color: #111111;\">\uff5e\/.npm<\/code>\u4e0b\u6709\u538b\u7f29\u5305\uff0c\u4f46\u662f\u6ca1\u6709\u5b89\u88c5\u5728<code style=\"color: #111111;\">node_modules<\/code>\u76ee\u5f55\u4e2d\uff0cnpm \u4f9d\u7136\u4f1a\u4ece\u8fdc\u7a0b\u4ed3\u5e93\u4e0b\u8f7d\u4e00\u6b21\u65b0\u7684\u538b\u7f29\u5305\u3002<\/p>\n<p style=\"color: #111111;\">\u8fd9\u79cd\u884c\u4e3a\u56fa\u7136\u53ef\u4ee5\u4fdd\u8bc1\u603b\u662f\u53d6\u5f97\u6700\u65b0\u7684\u4ee3\u7801\uff0c\u4f46\u6709\u65f6\u5e76\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u3002\u6700\u5927\u7684\u95ee\u9898\u662f\uff0c\u5b83\u4f1a\u6781\u5927\u5730\u5f71\u54cd\u5b89\u88c5\u901f\u5ea6\u3002\u5373\u4f7f\u67d0\u4e2a\u6a21\u5757\u7684\u538b\u7f29\u5305\u5c31\u5728\u7f13\u5b58\u76ee\u5f55\u4e2d\uff0c\u4e5f\u8981\u53bb\u8fdc\u7a0b\u4ed3\u5e93\u4e0b\u8f7d\uff0c\u8fd9\u600e\u4e48\u53ef\u80fd\u4e0d\u6162\u5462\uff1f<\/p>\n<p style=\"color: #111111;\">\u53e6\u5916\uff0c\u6709\u4e9b\u573a\u5408\u6ca1\u6709\u7f51\u7edc\uff08\u6bd4\u5982\u98de\u673a\u4e0a\uff09\uff0c\u4f46\u662f\u4f60\u60f3\u5b89\u88c5\u7684\u6a21\u5757\uff0c\u660e\u660e\u5c31\u5728\u7f13\u5b58\u76ee\u5f55\u4e4b\u4e2d\uff0c\u8fd9\u65f6\u4e5f\u65e0\u6cd5\u5b89\u88c5\u3002<\/p>\n<h2 style=\"font-weight: 500; color: #000000;\">\u516d\u3001<code style=\"color: #111111;\">--cache-min<\/code>\u00a0\u53c2\u6570<\/h2>\n<p style=\"color: #111111;\">\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0cnpm \u63d0\u4f9b\u4e86\u4e00\u4e2a<code style=\"color: #111111;\">--cache-min<\/code>\u53c2\u6570\uff0c\u7528\u4e8e\u4ece\u7f13\u5b58\u76ee\u5f55\u5b89\u88c5\u6a21\u5757\u3002<\/p>\n<p style=\"color: #111111;\"><code style=\"color: #111111;\">--cache-min<\/code>\u53c2\u6570\u6307\u5b9a\u4e00\u4e2a\u65f6\u95f4\uff08\u5355\u4f4d\u4e3a\u5206\u949f\uff09\uff0c\u53ea\u6709\u8d85\u8fc7\u8fd9\u4e2a\u65f6\u95f4\u7684\u6a21\u5757\uff0c\u624d\u4f1a\u4ece registry \u4e0b\u8f7d\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm install <span class=\"token operator\" style=\"color: #a67f59;\">--<\/span>cache<span class=\"token operator\" style=\"color: #a67f59;\">-<\/span>min <span class=\"token number\" style=\"color: #990055;\">9999999<\/span> <span class=\"token operator\" style=\"color: #a67f59;\">&lt;<\/span>package<span class=\"token operator\" style=\"color: #a67f59;\">-<\/span>name<span class=\"token operator\" style=\"color: #a67f59;\">&gt;<\/span>\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u4e0a\u9762\u547d\u4ee4\u6307\u5b9a\uff0c\u53ea\u6709\u8d85\u8fc7999999\u5206\u949f\u7684\u6a21\u5757\uff0c\u624d\u4ece registry \u4e0b\u8f7d\u3002\u5b9e\u9645\u4e0a\u5c31\u662f\u6307\u5b9a\uff0c\u6240\u6709\u6a21\u5757\u90fd\u4ece\u7f13\u5b58\u5b89\u88c5\uff0c\u8fd9\u6837\u5c31\u5927\u5927\u52a0\u5feb\u4e86\u4e0b\u8f7d\u901f\u5ea6\u3002<\/p>\n<p style=\"color: #111111;\">\u5b83\u8fd8\u6709\u53e6\u4e00\u79cd\u5199\u6cd5\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm install <span class=\"token operator\" style=\"color: #a67f59;\">--<\/span>cache<span class=\"token operator\" style=\"color: #a67f59;\">-<\/span>min Infinity <span class=\"token operator\" style=\"color: #a67f59;\">&lt;<\/span>package<span class=\"token operator\" style=\"color: #a67f59;\">-<\/span>name<span class=\"token operator\" style=\"color: #a67f59;\">&gt;<\/span>\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u4f46\u662f\uff0c\u8fd9\u5e76\u4e0d\u7b49\u4e8e\u79bb\u7ebf\u6a21\u5f0f\uff0c\u8fd9\u65f6<a style=\"color: #112233;\" href=\"https:\/\/github.com\/npm\/npm\/issues\/2568#issuecomment-172430897\" target=\"_blank\">\u4ecd\u7136\u9700\u8981<\/a>\u7f51\u7edc\u8fde\u63a5\u3002\u56e0\u4e3a\u73b0\u5728\u7684<code style=\"color: #111111;\">--cache-min<\/code>\u5b9e\u73b0\u6709\u4e00\u4e9b\u95ee\u9898\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<p style=\"color: #111111;\">\uff081\uff09\u5982\u679c\u6307\u5b9a\u6a21\u5757\u4e0d\u5728\u7f13\u5b58\u76ee\u5f55\uff0c\u90a3\u4e48 npm \u4f1a\u8fde\u63a5 registry\uff0c\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u3002\u8fd9\u6ca1\u6709\u95ee\u9898\uff0c\u4f46\u662f\u5982\u679c\u6307\u5b9a\u6a21\u5757\u5728\u7f13\u5b58\u76ee\u5f55\u4e4b\u4e2d\uff0cnpm \u4e5f\u4f1a<a style=\"color: #112233;\" href=\"https:\/\/github.com\/npm\/npm\/issues\/2568#issuecomment-171472949\" target=\"_blank\">\u8fde\u63a5 registry<\/a>\uff0c\u53d1\u51fa\u6307\u5b9a\u6a21\u5757\u7684 etag \uff0c\u670d\u52a1\u5668\u8fd4\u56de\u72b6\u6001\u7801304\uff0c\u8868\u793a\u4e0d\u9700\u8981\u91cd\u65b0\u4e0b\u8f7d\u538b\u7f29\u5305\u3002<\/p>\n<p style=\"color: #111111;\">\uff082\uff09\u5982\u679c\u67d0\u4e2a\u6a21\u5757\u5df2\u7ecf\u5728\u7f13\u5b58\u4e4b\u4e2d\uff0c\u4f46\u662f\u7248\u672c\u4f4e\u4e8e\u8981\u6c42\uff0cnpm\u4f1a<a style=\"color: #112233;\" href=\"https:\/\/github.com\/npm\/npm\/issues\/8581\" target=\"_blank\">\u76f4\u63a5\u62a5\u9519<\/a>\uff0c\u800c\u4e0d\u662f\u53bb registry \u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/blockquote>\n<p style=\"color: #111111;\">npm \u56e2\u961f<a style=\"color: #112233;\" href=\"https:\/\/github.com\/npm\/npm\/issues\/2568#issuecomment-53077253\" target=\"_blank\">\u77e5\u9053<\/a>\u5b58\u5728\u8fd9\u4e9b\u95ee\u9898\uff0c\u6b63\u5728<a style=\"color: #112233;\" href=\"https:\/\/github.com\/npm\/npm\/milestones\/cache%20rewrite\" target=\"_blank\">\u91cd\u5199 cache<\/a>\u3002\u5e76\u4e14\uff0c\u5c06\u6765\u4f1a\u63d0\u4f9b\u4e00\u4e2a<code style=\"color: #111111;\">--offline<\/code>\u53c2\u6570\uff0c\u4f7f\u5f97 npm \u53ef\u4ee5\u5728\u79bb\u7ebf\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002<\/p>\n<p style=\"color: #111111;\">\u4e0d\u8fc7\uff0c\u8fd9\u4e9b\u6539\u8fdb\u6ca1\u6709\u65e5\u7a0b\u8868\u3002\u6240\u4ee5\uff0c\u5f53\u524d\u4f7f\u7528<code style=\"color: #111111;\">--cache-min<\/code>\u6539\u8fdb\u5b89\u88c5\u901f\u5ea6\uff0c\u662f\u6709\u95ee\u9898\u7684\u3002<\/p>\n<h2 style=\"font-weight: 500; color: #000000;\">\u4e03\u3001\u79bb\u7ebf\u5b89\u88c5\u7684\u89e3\u51b3\u65b9\u6848<\/h2>\n<p style=\"color: #111111;\">\u793e\u533a\u5df2\u7ecf\u4e3anpm\u7684\u79bb\u7ebf\u4f7f\u7528\uff0c\u63d0\u51fa\u4e86\u51e0\u79cd\u89e3\u51b3\u65b9\u6848\u3002\u5b83\u4eec\u53ef\u4ee5\u5927\u5927\u52a0\u5feb\u6a21\u5757\u5b89\u88c5\u7684\u901f\u5ea6\u3002<\/p>\n<p style=\"color: #111111;\">\u89e3\u51b3\u65b9\u6848\u5927\u81f4\u5206\u6210\u4e09\u7c7b\u3002<\/p>\n<p style=\"color: #111111;\"><strong style=\"font-weight: 800;\">\u7b2c\u4e00\u7c7b\uff0cRegistry \u4ee3\u7406\u3002<\/strong><\/p>\n<blockquote style=\"color: #111111;\">\n<ul style=\"color: #111111;\">\n<li style=\"color: #111111;\"><a style=\"color: #112233;\" href=\"https:\/\/www.npmjs.com\/package\/npm-proxy-cache\" target=\"_blank\">npm-proxy-cache<\/a><\/li>\n<li style=\"color: #111111;\"><a style=\"color: #112233;\" href=\"https:\/\/github.com\/nolanlawson\/local-npm\" target=\"_blank\">local-npm<\/a>\uff08<a style=\"color: #112233;\" href=\"https:\/\/addyosmani.com\/blog\/using-npm-offline\/\" target=\"_blank\">\u7528\u6cd5<\/a>\uff09<\/li>\n<li style=\"color: #111111;\"><a style=\"color: #112233;\" href=\"https:\/\/github.com\/mixu\/npm_lazy\" target=\"_blank\">npm-lazy<\/a><\/li>\n<\/ul>\n<\/blockquote>\n<p style=\"color: #111111;\">\u4e0a\u9762\u4e09\u4e2a\u6a21\u5757\u7684\u7528\u6cd5\u5f88\u7c7b\u4f3c\uff0c\u90fd\u662f\u5728\u672c\u673a\u8d77\u4e00\u4e2a Registry \u670d\u52a1\uff0c\u6240\u6709<code style=\"color: #111111;\">npm install<\/code>\u547d\u4ee4\u90fd\u8981\u901a\u8fc7\u8fd9\u4e2a\u670d\u52a1\u4ee3\u7406\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n<span class=\"token comment\" style=\"color: slategray;\" spellcheck=\"true\"># npm-proxy-cache\r\n<\/span>$ npm <span class=\"token operator\" style=\"color: #a67f59;\">--<\/span>proxy http<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>localhost<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token number\" style=\"color: #990055;\">8080<\/span> \\\r\n  <span class=\"token operator\" style=\"color: #a67f59;\">--<\/span>https<span class=\"token operator\" style=\"color: #a67f59;\">-<\/span>proxy http<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>localhost<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token number\" style=\"color: #990055;\">8080<\/span> \\\r\n  <span class=\"token operator\" style=\"color: #a67f59;\">--<\/span>strict<span class=\"token operator\" style=\"color: #a67f59;\">-<\/span>ssl <span class=\"token boolean\" style=\"color: #990055;\">false<\/span> \\\r\n  install\r\n\r\n<span class=\"token comment\" style=\"color: slategray;\" spellcheck=\"true\"># local-npm\r\n<\/span>$ npm <span class=\"token keyword\" style=\"color: #0077aa;\">set<\/span> registry http<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token number\" style=\"color: #990055;\">127.0<\/span><span class=\"token punctuation\" style=\"color: #999999;\">.<\/span><span class=\"token number\" style=\"color: #990055;\">0.1<\/span><span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token number\" style=\"color: #990055;\">5080<\/span>\r\n\r\n<span class=\"token comment\" style=\"color: slategray;\" spellcheck=\"true\"># npm-lazy\r\n<\/span>$ npm <span class=\"token operator\" style=\"color: #a67f59;\">--<\/span>registry http<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span>localhost<span class=\"token punctuation\" style=\"color: #999999;\">:<\/span><span class=\"token number\" style=\"color: #990055;\">8080<\/span><span class=\"token operator\" style=\"color: #a67f59;\">\/<\/span> install socket<span class=\"token punctuation\" style=\"color: #999999;\">.<\/span>io\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\">\u6709\u4e86\u672c\u673a\u7684Registry\u670d\u52a1\uff0c\u5c31\u80fd\u5b8c\u5168\u5b9e\u73b0\u7f13\u5b58\u5b89\u88c5\uff0c\u53ef\u4ee5\u5b9e\u73b0\u79bb\u7ebf\u4f7f\u7528\u3002<\/p>\n<p style=\"color: #111111;\"><strong style=\"font-weight: 800;\">\u7b2c\u4e8c\u7c7b\uff0c<code style=\"color: #111111;\">npm install<\/code>\u66ff\u4ee3\u3002<\/strong><\/p>\n<p style=\"color: #111111;\">\u5982\u679c\u80fd\u591f\u6539\u53d8<code style=\"color: #111111;\">npm install<\/code>\u7684\u884c\u4e3a\uff0c\u5c31\u80fd\u5b9e\u73b0\u7f13\u5b58\u5b89\u88c5\u3002<a style=\"color: #112233;\" href=\"https:\/\/www.npmjs.com\/package\/npm-cache\" target=\"_blank\"><code style=\"color: #111111;\">npm-cache<\/code><\/a>\u00a0\u5de5\u5177\u5c31\u662f\u8fd9\u4e2a\u601d\u8def\u3002\u51e1\u662f\u4f7f\u7528<code style=\"color: #111111;\">npm install<\/code>\u7684\u5730\u65b9\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528<code style=\"color: #111111;\">npm-cache<\/code>\u66ff\u4ee3\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<pre class=\" language-bash\" style=\"color: black;\"><code class=\" language-bash\" style=\"color: black;\">\r\n$ npm<span class=\"token operator\" style=\"color: #a67f59;\">-<\/span>cache install\r\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"color: #111111;\"><strong style=\"font-weight: 800;\">\u7b2c\u4e09\u7c7b\uff0c<code style=\"color: #111111;\">node_modules<\/code>\u4f5c\u4e3a\u7f13\u5b58\u76ee\u5f55\u3002<\/strong><\/p>\n<p style=\"color: #111111;\">\u8fd9\u4e2a\u65b9\u6848\u7684\u601d\u8def\u662f\uff0c\u4e0d\u4f7f\u7528<code style=\"color: #111111;\">.npm<\/code>\u7f13\u5b58\uff0c\u800c\u662f\u4f7f\u7528\u9879\u76ee\u7684<code style=\"color: #111111;\">node_modules<\/code>\u76ee\u5f55\u4f5c\u4e3a\u7f13\u5b58\u3002<\/p>\n<blockquote style=\"color: #111111;\">\n<ul style=\"color: #111111;\">\n<li style=\"color: #111111;\"><a style=\"color: #112233;\" href=\"https:\/\/github.com\/node-freight\/freight\" target=\"_blank\">Freight<\/a><\/li>\n<li style=\"color: #111111;\"><a style=\"color: #112233;\" href=\"https:\/\/github.com\/arei\/npmbox\" target=\"_blank\">npmbox<\/a><\/li>\n<\/ul>\n<\/blockquote>\n<p style=\"color: #111111;\">\u4e0a\u9762\u4e24\u4e2a\u5de5\u5177\uff0c\u90fd\u80fd\u5c06\u9879\u76ee\u7684<code style=\"color: #111111;\">node_modules<\/code>\u76ee\u5f55\u6253\u6210\u4e00\u4e2a\u538b\u7f29\u5305\uff0c\u4ee5\u540e\u5b89\u88c5\u7684\u65f6\u5019\uff0c\u5c31\u4ece\u8fd9\u4e2a\u538b\u7f29\u5305\u4e4b\u4e2d\u53d6\u51fa\u6587\u4ef6\u3002<\/p>\n<p style=\"color: #111111;\">\uff08\u5b8c\uff09<\/p>\n<p><a href=\"http:\/\/www.ruanyifeng.com\/blog\/2016\/01\/npm-install.html\" target=\"_blank\">http:\/\/www.ruanyifeng.com\/blog\/2016\/01\/npm-install.html\u00a0<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>npm \u7b14\u8bb0 \u4e00\u3001\u4ece npm install \u8bf4\u8d77 npm install\u00a0\u547d\u4ee4\u7528\u6765\u5b89\u88c5\u6a21\u5757\u5230node_mod [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-5639","post","type-post","status-publish","format-standard","hentry","category-nodejs"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5639"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5639\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}