{"id":12861,"date":"2023-10-10T12:55:52","date_gmt":"2023-10-10T04:55:52","guid":{"rendered":"https:\/\/92it.top\/?p=12861"},"modified":"2023-10-10T17:50:41","modified_gmt":"2023-10-10T09:50:41","slug":"%e8%81%8a%e8%81%8apackage-json-%e5%92%8c-package-lock-json","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=12861","title":{"rendered":"\u804a\u804apackage.json \u548c package-lock.json"},"content":{"rendered":"\n<p>\u539f\u6587\u94fe\u63a5\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.cnblogs.com\/yalong\/p\/15013880.html\" target=\"_blank\">https:\/\/www.cnblogs.com\/yalong\/p\/15013880.html<\/a><\/p>\n\n\n\n<p>package.json \u8ddf package-lock.json \u7684\u77e5\u8bc6\u70b9\u633a\u591a\u7684\uff0c \u8fd9\u91cc\u53ea\u804a\u4e00\u804a\u90e8\u5206\u77e5\u8bc6\u70b9<\/p>\n\n\n\n<p><strong>\u5148\u770b\u4e0bdependencies\u4e0edevDependencies<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>npm install \u5b89\u88c5\u4f9d\u8d56\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u65b9\u5f0f\uff0c\u628a\u4f9d\u8d56\u5199\u5165package.json<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">npm install --save     \u6216\u8005  npm install -S\nnpm install --save-dev \u6216\u8005  npm install -D<\/pre>\n\n\n\n<p>dependencies\u4e0edevDependencies\u7684\u533a\u522b\uff1a<\/p>\n\n\n\n<p>devDependencies\u4e0b\u5217\u51fa\u7684\u6a21\u5757\uff0c\u662f\u6211\u4eec\u5f00\u53d1\u65f6\u7528\u7684\u4f9d\u8d56\u9879\uff0c\u50cf\u4e00\u4e9b\u8fdb\u884c\u5355\u5143\u6d4b\u8bd5\u4e4b\u7c7b\u7684\u5305\uff0c\u6bd4\u5982jest\uff0c\u6211\u4eec\u7528\u5199\u5355\u5143\u6d4b\u8bd5\uff0c\u5b83\u4eec\u4e0d\u4f1a\u88ab\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u3002dependencies\u4e0b\u7684\u6a21\u5757\uff0c\u5219\u662f\u6211\u4eec\u751f\u4ea7\u73af\u5883\u4e2d\u9700\u8981\u7684\u4f9d\u8d56\uff0c\u5373\u6b63\u5e38\u8fd0\u884c\u8be5\u5305\u65f6\u6240\u9700\u8981\u7684\u4f9d\u8d56\u9879\u3002<\/p>\n\n\n\n<p>\u8bb0\u7740\u8fd9\u53e5: &#8220;\u6b63\u5e38\u8fd0\u884c\u8be5\u5305\u65f6\u6240\u9700\u8981\u7684\u4f9d\u8d56\u9879&#8221;<br>\u540e\u9762\u7684package-lock.json \u4e2d\u7684 dependencies \u5bf9\u5e94\u7684\u5c31\u662fpackage.json\u4e2d\u7684 dependencies<\/p>\n\n\n\n<p><strong>Package.json \u8bed\u4e49\u5316\u7248\u672c<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4f7f\u7528\u7b2c\u4e09\u65b9\u4f9d\u8d56\u65f6\uff0c\u901a\u5e38\u9700\u8981\u6307\u5b9a\u4f9d\u8d56\u7684\u7248\u672c\u8303\u56f4\uff0c\u6bd4\u5982<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\"dependencies\": {\n    \"antd\": \"3.1.2\",\n    \"react\": \"~16.0.1\",\n    \"redux\": \"^3.7.2\",\n    \"lodash\": \"*\"\n  }<\/pre>\n\n\n\n<p>\u4e0a\u9762\u7684 package.json \u6587\u4ef6\u8868\u660e\uff0c\u9879\u76ee\u4e2d\u4f7f\u7528\u7684 antd \u7684\u7248\u672c\u53f7\u662f 3.1.2\uff0c\u4f46\u662f 3.1.1 \u548c 3.1.2\u30013.0.1\u30012.1.1 \u4e4b\u95f4\u6709\u4ec0\u4e48\u4e0d\u540c\u5462\u3002<\/p>\n\n\n\n<p>\u8bed\u4e49\u5316\u7248\u672c\u89c4\u5219\u89c4\u5b9a\uff0c\u7248\u672c\u683c\u5f0f\u4e3a\uff1a<code>\u4e3b\u7248\u672c\u53f7.\u6b21\u7248\u672c\u53f7.\u4fee\u8ba2\u53f7<\/code>\uff0c\u5e76\u4e14\u7248\u672c\u53f7\u7684\u9012\u589e\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul><li>\u4e3b\u7248\u672c\u53f7\uff1a\u5f53\u4f60\u505a\u4e86\u4e0d\u517c\u5bb9\u7684 API \u4fee\u6539<\/li><li>\u6b21\u7248\u672c\u53f7\uff1a\u5f53\u4f60\u505a\u4e86\u5411\u4e0b\u517c\u5bb9\u7684\u529f\u80fd\u6027\u65b0\u589e<\/li><li>\u4fee\u8ba2\u53f7\uff1a\u5f53\u4f60\u505a\u4e86\u5411\u4e0b\u517c\u5bb9\u7684\u95ee\u9898\u4fee\u6b63<\/li><\/ul>\n\n\n\n<p>\u4e3b\u7248\u672c\u53f7\u7684\u66f4\u65b0\u901a\u5e38\u610f\u5473\u7740\u5927\u7684\u4fee\u6539\u548c\u66f4\u65b0\uff0c\u5347\u7ea7\u4e3b\u7248\u672c\u540e\u53ef\u80fd\u4f1a\u4f7f\u4f60\u7684\u7a0b\u5e8f\u62a5\u9519\uff0c\u56e0\u6b64\u5347\u7ea7\u4e3b\u7248\u672c\u53f7\u9700\u8c28\u614e\uff0c\u4f46\u662f\u8fd9\u5f80\u5f80\u4e5f\u4f1a\u5e26\u6765\u66f4\u597d\u7684\u6027\u80fd\u548c\u4f53\u9a8c\u3002<\/p>\n\n\n\n<p>\u6b21\u7248\u672c\u53f7\u7684\u66f4\u65b0\u5219\u901a\u5e38\u610f\u5473\u7740\u65b0\u589e\u4e86\u67d0\u4e9b\u7279\u6027\uff0c\u6bd4\u5982 antd \u7684\u7248\u672c\u4ece 3.1.1 \u5347\u7ea7\u5230 3.1.2\uff0c\u4e4b\u524d\u7684 Select \u7ec4\u4ef6\u4e0d\u652f\u6301\u641c\u7d22\u529f\u80fd\uff0c\u5347\u7ea7\u4e4b\u540e\u652f\u6301\u4e86\u641c\u7d22\u3002<\/p>\n\n\n\n<p>\u4fee\u8ba2\u53f7\u7684\u66f4\u65b0\u5219\u5f80\u5f80\u610f\u5473\u7740\u8fdb\u884c\u4e86\u4e00\u4e9b bug \u4fee\u590d\u3002\u56e0\u6b64\u6b21\u7248\u672c\u53f7\u548c\u4fee\u8ba2\u53f7\u5e94\u8be5\u4fdd\u6301\u66f4\u65b0\uff0c\u8fd9\u6837\u80fd\u8ba9\u4f60\u4e4b\u524d\u7684\u4ee3\u7801\u4e0d\u4f1a\u62a5\u9519\u8fd8\u80fd\u83b7\u53d6\u5230\u6700\u65b0\u7684\u529f\u80fd\u7279\u6027\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\uff0c\u5f80\u5f80\u6211\u4eec\u4e0d\u4f1a\u6307\u5b9a\u4f9d\u8d56\u7684\u5177\u4f53\u7248\u672c\uff0c\u800c\u662f\u6307\u5b9a\u7248\u672c\u8303\u56f4\uff0c\u6bd4\u5982\u4e0a\u9762\u7684 package.json \u6587\u4ef6\u91cc\u7684 react\u3001redux \u4ee5\u53ca lodash\uff0c\u8fd9\u4e09\u4e2a\u4f9d\u8d56\u5206\u522b\u4f7f\u7528\u4e86\u4e09\u4e2a\u7b26\u53f7\u6765\u8868\u660e\u4f9d\u8d56\u7684\u7248\u672c\u8303\u56f4\u3002\u8bed\u4e49\u5316\u7248\u672c\u8303\u56f4\u89c4\u5b9a\uff1a<\/p>\n\n\n\n<ul><li>~\uff1a\u53ea\u5347\u7ea7\u4fee\u8ba2\u53f7<\/li><li>^\uff1a\u5347\u7ea7\u6b21\u7248\u672c\u53f7\u548c\u4fee\u8ba2\u53f7<\/li><li>*\uff1a\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c<\/li><\/ul>\n\n\n\n<p>\u56e0\u6b64\uff0c\u4e0a\u9762\u7684 package.json \u6587\u4ef6\u5b89\u88c5\u7684\u4f9d\u8d56\u7248\u672c\u8303\u56f4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">react@~16.0.1\uff1a>=react@16.0.1 &amp;&amp; &lt; react@16.1.0\nredux@^3.7.2\uff1a>=redux@3.7.2 &amp;&amp; &lt; redux@4.0.0\nlodash@*\uff1alodash@latest\n<\/pre>\n\n\n\n<p>\u8bed\u4e49\u5316\u7248\u672c\u89c4\u5219\u5b9a\u4e49\u4e86\u4e00\u79cd\u7406\u60f3\u7684\u7248\u672c\u53f7\u66f4\u65b0\u89c4\u5219\uff0c\u5e0c\u671b\u6240\u6709\u7684\u4f9d\u8d56\u66f4\u65b0\u90fd\u80fd\u9075\u5faa\u8fd9\u4e2a\u89c4\u5219\uff0c\u4f46\u662f\u5f80\u5f80\u4f1a\u6709\u8bb8\u591a\u4f9d\u8d56\u4e0d\u662f\u4e25\u683c\u9075\u5faa\u8fd9\u4e9b\u89c4\u5b9a\u7684\u3002<br>\u56e0\u6b64\uff0c\u5982\u4f55\u7ba1\u7406\u597d\u8fd9\u4e9b\u4f9d\u8d56\uff0c\u5c24\u5176\u662f\u8fd9\u4e9b\u4f9d\u8d56\u7684\u7248\u672c\u5c31\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\uff0c\u5426\u5219\u4e00\u4e0d\u5c0f\u5fc3\u5c31\u4f1a\u9677\u5165\u56e0\u4f9d\u8d56\u7248\u672c\u4e0d\u4e00\u81f4\u5bfc\u81f4\u7684\u5404\u79cd\u95ee\u9898\u4e2d\u3002<\/p>\n\n\n\n<p><strong>npm\u7684\u5386\u53f2\u53d8\u8fc1<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u5d4c\u5957\u7ed3\u6784\">\u5d4c\u5957\u7ed3\u6784<\/h4>\n\n\n\n<p>\u6211\u4eec\u90fd\u77e5\u9053\uff0c\u6267\u884c npm install \u540e\uff0c\u4f9d\u8d56\u5305\u88ab\u5b89\u88c5\u5230\u4e86 node_modules \uff0c\u4e0b\u9762\u6211\u4eec\u6765\u5177\u4f53\u4e86\u89e3\u4e0b\uff0cnpm \u5c06\u4f9d\u8d56\u5305\u5b89\u88c5\u5230 node_modules \u7684\u5177\u4f53\u673a\u5236\u662f\u4ec0\u4e48\u3002<\/p>\n\n\n\n<p>\u5728 npm \u7684\u65e9\u671f\u7248\u672c\uff0c npm \u5904\u7406\u4f9d\u8d56\u7684\u65b9\u5f0f\u7b80\u5355\u7c97\u66b4\uff0c\u4ee5\u9012\u5f52\u7684\u5f62\u5f0f\uff0c\u4e25\u683c\u6309\u7167 package.json \u7ed3\u6784\u4ee5\u53ca\u5b50\u4f9d\u8d56\u5305\u7684 package.json \u7ed3\u6784\u5c06\u4f9d\u8d56\u5b89\u88c5\u5230\u4ed6\u4eec\u5404\u81ea\u7684 node_modules \u4e2d\u3002\u76f4\u5230\u6709\u5b50\u4f9d\u8d56\u5305\u4e0d\u5728\u4f9d\u8d56\u5176\u4ed6\u6a21\u5757\u3002<\/p>\n\n\n\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u7684\u6a21\u5757 my-app \u73b0\u5728\u4f9d\u8d56\u4e86\u4e24\u4e2a\u6a21\u5757\uff1abuffer\u3001ignore\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n  \"name\": \"my-app\",\n  \"dependencies\": {\n    \"buffer\": \"^5.4.3\",\n    \"ignore\": \"^5.1.4\",\n  }\n}<\/pre>\n\n\n\n<p>ignore\u662f\u4e00\u4e2a\u7eaf JS \u6a21\u5757\uff0c\u4e0d\u4f9d\u8d56\u4efb\u4f55\u5176\u4ed6\u6a21\u5757\uff0c\u800c buffer \u53c8\u4f9d\u8d56\u4e86\u4e0b\u9762\u4e24\u4e2a\u6a21\u5757\uff1abase64-js \u3001 ieee754\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n  \"name\": \"buffer\",\n  \"dependencies\": {\n    \"base64-js\": \"^1.0.2\",\n    \"ieee754\": \"^1.1.4\"\n  }\n}\n<\/pre>\n\n\n\n<p>\u90a3\u4e48\uff0c\u6267\u884c npm install \u540e\uff0c\u5f97\u5230\u7684 node_modules \u4e2d\u6a21\u5757\u76ee\u5f55\u7ed3\u6784\u5c31\u662f\u4e0b\u9762\u8fd9\u6837\u7684\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1024x538.png\" alt=\"\" class=\"wp-image-12862\" width=\"472\" height=\"248\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1024x538.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-300x157.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-768x403.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1536x806.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2048x1075.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-830x436.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-230x121.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-350x184.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-480x252.png 480w\" sizes=\"(max-width: 472px) 100vw, 472px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fd9\u6837\u7684\u65b9\u5f0f\u4f18\u70b9\u5f88\u660e\u663e\uff0c node_modules \u7684\u7ed3\u6784\u548c package.json \u7ed3\u6784\u4e00\u4e00\u5bf9\u5e94\uff0c\u5c42\u7ea7\u7ed3\u6784\u660e\u663e\uff0c\u5e76\u4e14\u4fdd\u8bc1\u4e86\u6bcf\u6b21\u5b89\u88c5\u76ee\u5f55\u7ed3\u6784\u90fd\u662f\u76f8\u540c\u7684\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\uff0c\u8bd5\u60f3\u4e00\u4e0b\uff0c\u5982\u679c\u4f60\u4f9d\u8d56\u7684\u6a21\u5757\u975e\u5e38\u4e4b\u591a\uff0c\u4f60\u7684 node_modules \u5c06\u975e\u5e38\u5e9e\u5927\uff0c\u5d4c\u5957\u5c42\u7ea7\u975e\u5e38\u4e4b\u6df1\uff1a<\/p>\n\n\n\n<ul><li>\u5728\u4e0d\u540c\u5c42\u7ea7\u7684\u4f9d\u8d56\u4e2d\uff0c\u53ef\u80fd\u5f15\u7528\u4e86\u540c\u4e00\u4e2a\u6a21\u5757\uff0c\u5bfc\u81f4\u5927\u91cf\u5197\u4f59\u3002<\/li><li>\u5728 Windows \u7cfb\u7edf\u4e2d\uff0c\u6587\u4ef6\u8def\u5f84\u6700\u5927\u957f\u5ea6\u4e3a260\u4e2a\u5b57\u7b26\uff0c\u5d4c\u5957\u5c42\u7ea7\u8fc7\u6df1\u53ef\u80fd\u5bfc\u81f4\u4e0d\u53ef\u9884\u77e5\u7684\u95ee\u9898\u3002<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u6241\u5e73\u7ed3\u6784\">\u6241\u5e73\u7ed3\u6784<\/h4>\n\n\n\n<p>\u4e3a\u4e86\u89e3\u51b3\u4ee5\u4e0a\u95ee\u9898\uff0cNPM \u5728 3.x \u7248\u672c\u505a\u4e86\u4e00\u6b21\u8f83\u5927\u66f4\u65b0\u3002\u5176\u5c06\u65e9\u671f\u7684\u5d4c\u5957\u7ed3\u6784\u6539\u4e3a\u6241\u5e73\u7ed3\u6784\uff1a<\/p>\n\n\n\n<ul><li>\u5b89\u88c5\u6a21\u5757\u65f6\uff0c\u4e0d\u7ba1\u5176\u662f\u76f4\u63a5\u4f9d\u8d56\u8fd8\u662f\u5b50\u4f9d\u8d56\u7684\u4f9d\u8d56\uff0c\u4f18\u5148\u5c06\u5176\u5b89\u88c5\u5728 node_modules \u6839\u76ee\u5f55\u3002<br>\u8fd8\u662f\u4e0a\u9762\u7684\u4f9d\u8d56\u7ed3\u6784\uff0c\u6211\u4eec\u5728\u6267\u884c npm install \u540e\u5c06\u5f97\u5230\u4e0b\u9762\u7684\u76ee\u5f55\u7ed3\u6784\uff1a\\<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1.png\" alt=\"\" class=\"wp-image-12863\" width=\"521\" height=\"159\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1.png 746w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1-300x92.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1-230x70.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1-350x107.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-1-480x147.png 480w\" sizes=\"(max-width: 521px) 100vw, 521px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-1024x519.png\" alt=\"\" class=\"wp-image-12864\" width=\"517\" height=\"261\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-1024x519.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-300x152.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-1536x779.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-2048x1039.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-830x421.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-230x117.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-350x178.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-2-480x243.png 480w\" sizes=\"(max-width: 517px) 100vw, 517px\" \/><\/figure><\/div>\n\n\n\n<p>\u6b64\u65f6\u6211\u4eec\u82e5\u5728\u6a21\u5757\u4e2d\u53c8\u4f9d\u8d56\u4e86 base64-js@1.0.1 \u7248\u672c\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\n{\n  \"name\": \"my-app\",\n  \"dependencies\": {\n    \"buffer\": \"^5.4.3\",\n    \"ignore\": \"^5.1.4\",\n    \"base64-js\": \"1.0.1\",\n  }\n}\n<\/pre>\n\n\n\n<ul><li>\u5f53\u5b89\u88c5\u5230\u76f8\u540c\u6a21\u5757\u65f6\uff0c\u5224\u65ad\u5df2\u5b89\u88c5\u7684\u6a21\u5757\u7248\u672c\u662f\u5426\u7b26\u5408\u65b0\u6a21\u5757\u7684\u7248\u672c\u8303\u56f4\uff0c\u5982\u679c\u7b26\u5408\u5219\u8df3\u8fc7\uff0c\u4e0d\u7b26\u5408\u5219\u5728\u5f53\u524d\u6a21\u5757\u7684 node_modules \u4e0b\u5b89\u88c5\u8be5\u6a21\u5757\u3002<\/li><\/ul>\n\n\n\n<p>\u6b64\u65f6\uff0c\u6211\u4eec\u5728\u6267\u884c npm install \u540e\u5c06\u5f97\u5230\u4e0b\u9762\u7684\u76ee\u5f55\u7ed3\u6784\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-3.png\" alt=\"\" class=\"wp-image-12865\" width=\"547\" height=\"329\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-3.png 948w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-3-300x180.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-3-768x462.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-3-830x499.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-3-230x138.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-3-350x210.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-3-480x289.png 480w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/><\/figure><\/div>\n\n\n\n<p>\u5bf9\u5e94\u7684\uff0c\u5982\u679c\u6211\u4eec\u5728\u9879\u76ee\u4ee3\u7801\u4e2d\u5f15\u7528\u4e86\u4e00\u4e2a\u6a21\u5757\uff0c\u6a21\u5757\u67e5\u627e\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul><li>\u5728\u5f53\u524d\u6a21\u5757\u8def\u5f84\u4e0b\u641c\u7d22<\/li><li>\u5728\u5f53\u524d\u6a21\u5757 node_modules \u8def\u5f84\u4e0b\u641c\u7d20<\/li><li>\u5728\u4e0a\u7ea7\u6a21\u5757\u7684 node_modules \u8def\u5f84\u4e0b\u641c\u7d22<\/li><li>&#8230;<\/li><li>\u76f4\u5230\u641c\u7d22\u5230\u5168\u5c40\u8def\u5f84\u4e2d\u7684 node_modules<\/li><\/ul>\n\n\n\n<p>\u5047\u8bbe\u6211\u4eec\u53c8\u4f9d\u8d56\u4e86\u4e00\u4e2a\u5305 buffer2@^5.4.3\uff0c\u800c\u5b83\u4f9d\u8d56\u4e86\u5305 base64-js@1.0.3\uff0c\u5219\u6b64\u65f6\u7684\u5b89\u88c5\u7ed3\u6784\u662f\u4e0b\u9762\u8fd9\u6837\u7684\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-1024x513.png\" alt=\"\" class=\"wp-image-12866\" width=\"498\" height=\"249\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-1024x513.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-300x150.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-768x385.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-1536x770.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-2048x1027.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-830x416.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-230x115.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-350x175.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-4-480x241.png 480w\" sizes=\"(max-width: 498px) 100vw, 498px\" \/><\/figure><\/div>\n\n\n\n<p>\u6240\u4ee5 npm 3.x \u7248\u672c\u5e76\u672a\u5b8c\u5168\u89e3\u51b3\u8001\u7248\u672c\u7684\u6a21\u5757\u5197\u4f59\u95ee\u9898\uff0c\u751a\u81f3\u8fd8\u4f1a\u5e26\u6765\u65b0\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u53e6\u5916\uff0c\u4e3a\u4e86\u8ba9\u5f00\u53d1\u8005\u5728\u5b89\u5168\u7684\u524d\u63d0\u4e0b\u4f7f\u7528\u6700\u65b0\u7684\u4f9d\u8d56\u5305\uff0c\u6211\u4eec\u5728 package.json \u901a\u5e38\u53ea\u4f1a\u9501\u5b9a\u5927\u7248\u672c\uff0c\u8fd9\u610f\u5473\u7740\u5728\u67d0\u4e9b\u4f9d\u8d56\u5305\u5c0f\u7248\u672c\u66f4\u65b0\u540e\uff0c\u540c\u6837\u53ef\u80fd\u9020\u6210\u4f9d\u8d56\u7ed3\u6784\u7684\u6539\u52a8\uff0c\u4f9d\u8d56\u7ed3\u6784\u7684\u4e0d\u786e\u5b9a\u6027\u53ef\u80fd\u4f1a\u7ed9\u7a0b\u5e8f\u5e26\u6765\u4e0d\u53ef\u9884\u77e5\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p><strong>Lock\u6587\u4ef6(package-lock.json)<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4e3a\u4e86\u89e3\u51b3 npm install \u7684\u4e0d\u786e\u5b9a\u6027\u95ee\u9898\uff0c\u5728 npm 5.x \u7248\u672c\u65b0\u589e\u4e86 package-lock.json \u6587\u4ef6\uff0c\u800c\u5b89\u88c5\u65b9\u5f0f\u8fd8\u6cbf\u7528\u4e86 npm 3.x \u7684\u6241\u5e73\u5316\u7684\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p>package-lock.json \u7684\u4f5c\u7528\u662f\u9501\u5b9a\u4f9d\u8d56\u7ed3\u6784\uff0c\u5373\u53ea\u8981\u4f60\u76ee\u5f55\u4e0b\u6709 package-lock.json \u6587\u4ef6\uff0c\u90a3\u4e48\u4f60\u6bcf\u6b21\u6267\u884c npm install \u540e\u751f\u6210\u7684 node_modules \u76ee\u5f55\u7ed3\u6784\u4e00\u5b9a\u662f\u5b8c\u5168\u76f8\u540c\u7684\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u6211\u4eec\u6709\u5982\u4e0b\u7684\u4f9d\u8d56\u7ed3\u6784\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n  \"name\": \"my-app\",\n  \"dependencies\": {\n    \"buffer\": \"^5.4.3\",\n    \"ignore\": \"^5.1.4\",\n    \"base64-js\": \"1.0.1\",\n  }\n}\n<\/pre>\n\n\n\n<p>\u5728\u6267\u884c npm install \u540e\u751f\u6210\u7684 package-lock.json \u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n  \"name\": \"my-app\",\n  \"version\": \"1.0.0\",\n  \"dependencies\": {\n    \"base64-js\": {\n      \"version\": \"1.0.1\",\n      \"resolved\": \"https:\/\/registry.npmjs.org\/base64-js\/-\/base64-js-1.0.1.tgz\",\n      \"integrity\": \"sha1-aSbRsZT7xze47tUTdW3i\/Np+pAg=\"\n    },\n    \"buffer\": {\n      \"version\": \"5.4.3\",\n      \"resolved\": \"https:\/\/registry.npmjs.org\/buffer\/-\/buffer-5.4.3.tgz\",\n      \"integrity\": \"sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o\/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==\",\n      \"requires\": {\n        \"base64-js\": \"^1.0.2\",\n        \"ieee754\": \"^1.1.4\"\n      },\n      \"dependencies\": {\n        \"base64-js\": {\n          \"version\": \"1.3.1\",\n          \"resolved\": \"https:\/\/registry.npmjs.org\/base64-js\/-\/base64-js-1.3.1.tgz\",\n          \"integrity\": \"sha512-mLQ4i2QO1ytvGWFWmcngKO\/\/JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==\"\n        }\n      }\n    },\n    \"ieee754\": {\n      \"version\": \"1.1.13\",\n      \"resolved\": \"https:\/\/registry.npmjs.org\/ieee754\/-\/ieee754-1.1.13.tgz\",\n      \"integrity\": \"sha512-4vf7I2LYV\/HaWerSo3XmlMkp5eZ83i+\/CDluXi\/IGTs\/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==\"\n    },\n    \"ignore\": {\n      \"version\": \"5.1.4\",\n      \"resolved\": \"https:\/\/registry.npmjs.org\/ignore\/-\/ignore-5.1.4.tgz\",\n      \"integrity\": \"sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==\"\n    }\n  }\n}<\/pre>\n\n\n\n<p>\u6211\u4eec\u6765\u5177\u4f53\u770b\u770b\u4e0a\u9762\u7684\u7ed3\u6784\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-1024x689.png\" alt=\"\" class=\"wp-image-12867\" width=\"510\" height=\"343\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-1024x689.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-300x202.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-768x517.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-1536x1033.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-830x558.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-230x155.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-350x235.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5-480x323.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-5.png 2040w\" sizes=\"(max-width: 510px) 100vw, 510px\" \/><\/figure><\/div>\n\n\n\n<p>\u6700\u5916\u9762\u7684\u4e24\u4e2a\u5c5e\u6027 name \u3001version \u540c package.json \u4e2d\u7684 name \u548c version \uff0c\u7528\u4e8e\u63cf\u8ff0\u5f53\u524d\u5305\u540d\u79f0\u548c\u7248\u672c\u3002<\/p>\n\n\n\n<p>dependencies \u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5bf9\u8c61\u548c node_modules \u4e2d\u7684\u5305\u7ed3\u6784\u4e00\u4e00\u5bf9\u5e94\uff0c\u5bf9\u8c61\u7684 key \u4e3a\u5305\u540d\u79f0\uff0c\u503c\u4e3a\u5305\u7684\u4e00\u4e9b\u63cf\u8ff0\u4fe1\u606f\uff1a<\/p>\n\n\n\n<ul><li>version\uff1a\u5305\u7248\u672c \u2014\u2014 \u8fd9\u4e2a\u5305\u5f53\u524d\u5b89\u88c5\u5728 node_modules \u4e2d\u7684\u7248\u672c<\/li><li>resolved\uff1a\u5305\u5177\u4f53\u7684\u5b89\u88c5\u6765\u6e90<\/li><li>integrity\uff1a\u5305 hash \u503c\uff0c\u57fa\u4e8e Subresource Integrity \u6765\u9a8c\u8bc1\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\u662f\u5426\u88ab\u6539\u52a8\u8fc7\u3001\u662f\u5426\u5df2\u5931\u6548<\/li><li>requires\uff1a\u5bf9\u5e94\u5b50\u4f9d\u8d56\u7684\u4f9d\u8d56\uff0c\u4e0e\u5b50\u4f9d\u8d56\u7684 package.json \u4e2d dependencies\u7684\u4f9d\u8d56\u9879\u76f8\u540c\u3002<\/li><li>dependencies\uff1a\u7ed3\u6784\u548c\u5916\u5c42\u7684 dependencies \u7ed3\u6784\u76f8\u540c\uff0c\u5b58\u50a8\u5b89\u88c5\u5728\u5b50\u4f9d\u8d56 node_modules \u4e2d\u7684\u4f9d\u8d56\u5305\u3002<\/li><\/ul>\n\n\n\n<p>\u8fd9\u91cc\u6ce8\u610f\uff0c\u5e76\u4e0d\u662f\u6240\u6709\u7684\u5b50\u4f9d\u8d56\u90fd\u6709 dependencies \u5c5e\u6027\uff0c\u53ea\u6709\u5b50\u4f9d\u8d56\u7684\u4f9d\u8d56\u548c\u5f53\u524d\u5df2\u5b89\u88c5\u5728\u6839\u76ee\u5f55\u7684 node_modules \u4e2d\u7684\u4f9d\u8d56\u51b2\u7a81\u4e4b\u540e\uff0c\u624d\u4f1a\u6709\u8fd9\u4e2a\u5c5e\u6027\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u56de\u987e\u4e0b\u4e0a\u9762\u7684\u4f9d\u8d56\u5173\u7cfb\uff1a<\/p>\n\n\n\n<p>\u6211\u4eec\u5728 my-app \u4e2d\u4f9d\u8d56\u7684 base64-js@1.0.1 \u7248\u672c\u4e0e buffer \u4e2d\u4f9d\u8d56\u7684 base64-js@^1.0.2 \u53d1\u751f\u51b2\u7a81\uff0c\u6240\u4ee5 base64-js@1.0.1 \u9700\u8981\u5b89\u88c5\u5728 buffer \u5305\u7684 node_modules \u4e2d\uff0c\u5bf9\u5e94\u4e86 package-lock.json \u4e2d buffer \u7684 dependencies \u5c5e\u6027\u3002\u8fd9\u4e5f\u5bf9\u5e94\u4e86 npm \u5bf9\u4f9d\u8d56\u7684\u6241\u5e73\u5316\u5904\u7406\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\uff0c\u6839\u636e\u4e0a\u9762\u7684\u5206\u6790\uff0c package-lock.json \u6587\u4ef6 \u548c node_modules \u76ee\u5f55\u7ed3\u6784\u662f\u4e00\u4e00\u5bf9\u5e94\u7684\uff0c\u5373\u9879\u76ee\u76ee\u5f55\u4e0b\u5b58\u5728 package-lock.json \u53ef\u4ee5\u8ba9\u6bcf\u6b21\u5b89\u88c5\u751f\u6210\u7684\u4f9d\u8d56\u76ee\u5f55\u7ed3\u6784\u4fdd\u6301\u76f8\u540c\u3002<\/p>\n\n\n\n<p><strong>package-lock.json\u7684\u4f5c\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5176\u5b9e\u7528\u4e00\u53e5\u8bdd\u6765\u6982\u62ec\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u9501\u5b9a\u5b89\u88c5\u65f6\u7684\u5305\u7684\u7248\u672c\u53f7\uff0c\u5e76\u4e14\u9700\u8981\u4e0a\u4f20\u5230git\uff0c\u4ee5\u4fdd\u8bc1\u5176\u4ed6\u4eba\u5728npm install\u65f6\u5927\u5bb6\u7684\u4f9d\u8d56\u80fd\u4fdd\u8bc1\u4e00\u81f4\u3002<\/p>\n\n\n\n<p>\u5f15\u7528\u77e5\u4e4e@\u5468\u8f7d\u5357\u7684\u56de\u7b54<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u6839\u636e\u5b98\u65b9\u6587\u6863\uff0c\u8fd9\u4e2apackage-lock.json \u662f\u5728 npm install\u65f6\u5019\u751f\u6210\u4e00\u4efd\u6587\u4ef6\uff0c\u7528\u4ee5\u8bb0\u5f55\u5f53\u524d\u72b6\u6001\u4e0b\u5b9e\u9645\u5b89\u88c5\u7684\u5404\u4e2anpm package\u7684\u5177\u4f53\u6765\u6e90\u548c\u7248\u672c\u53f7\u3002\n\n\u5b83\u6709\u4ec0\u4e48\u7528\u5462\uff1f\u56e0\u4e3anpm\u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406package\u4e4b\u95f4\u4f9d\u8d56\u5173\u7cfb\u7684\u7ba1\u7406\u5668\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u5728pacakge.json\u4e2d\u95f4\u6807\u51fa\u81ea\u5df1\u9879\u76ee\u5bf9npm\u5404\u5e93\u5305\u7684\u4f9d\u8d56\u3002\u4f60\u53ef\u4ee5\u9009\u62e9\u4ee5\u5982\u4e0b\u65b9\u5f0f\u6765\u6807\u660e\u81ea\u5df1\u6240\u9700\u8981\u5e93\u5305\u7684\u7248\u672c\n\n\u8fd9\u91cc\u4e3e\u4e2a\u4f8b\u5b50\uff1a\n\n\"dependencies\": {\n\"@types\/node\": \"^8.0.33\",\n},\n\n\u8fd9\u91cc\u9762\u7684 \u5411\u4e0a\u6807\u53f7^\u662f\u5b9a\u4e49\u4e86\u5411\u540e\uff08\u65b0\uff09\u517c\u5bb9\u4f9d\u8d56\uff0c\u6307\u5982\u679c types\/node\u7684\u7248\u672c\u662f\u8d85\u8fc78.0.33\uff0c\u5e76\u5728\u5927\u7248\u672c\u53f7\uff088\uff09\u4e0a\u76f8\u540c\uff0c\u5c31\u5141\u8bb8\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684 types\/node\u5e93\u5305\uff0c\u4f8b\u5982\u5b9e\u9645\u4e0a\u53ef\u80fd\u8fd0\u884cnpm install\u65f6\u5019\u4e0b\u8f7d\u7684\u5177\u4f53\u7248\u672c\u662f8.0.35\u3002\u6ce2\u6d6a\u53f7\n\n\u5927\u591a\u6570\u60c5\u51b5\u8fd9\u79cd\u5411\u65b0\u517c\u5bb9\u4f9d\u8d56\u4e0b\u8f7d\u6700\u65b0\u5e93\u5305\u7684\u65f6\u5019\u90fd\u6ca1\u6709\u95ee\u9898\uff0c\u53ef\u662f\u56e0\u4e3anpm\u662f\u5f00\u6e90\u4e16\u754c\uff0c\u5404\u5e93\u5305\u7684\u7248\u672c\u8bed\u4e49\u53ef\u80fd\u5e76\u4e0d\u76f8\u540c\uff0c\u6709\u7684\u5e93\u5305\u5f00\u53d1\u8005\u5e76\u4e0d\u9075\u5b88\u4e25\u683c\u8fd9\u4e00\u539f\u5219\uff1a\u76f8\u540c\u5927\u7248\u672c\u53f7\u7684\u540c\u4e00\u4e2a\u5e93\u5305\uff0c\u5176\u63a5\u53e3\u7b26\u5408\u517c\u5bb9\u8981\u6c42\u3002\u8fd9\u65f6\u5019\u7528\u6237\u5c31\u5f88\u5934\u75bc\u4e86\uff1a\u5728\u5b8c\u5168\u76f8\u540c\u7684\u4e00\u4e2anodejs\u7684\u4ee3\u7801\u5e93\uff0c\u5728\u4e0d\u540c\u65f6\u95f4\u6216\u8005\u4e0d\u540cnpm\u4e0b\u8f7d\u6e90\u4e4b\u4e0b\uff0c\u4e0b\u5230\u7684\u5404\u4f9d\u8d56\u5e93\u5305\u7248\u672c\u53ef\u80fd\u6709\u6240\u4e0d\u540c\uff0c\u56e0\u6b64\u5176\u4f9d\u8d56\u5e93\u5305\u884c\u4e3a\u7279\u5f81\u4e5f\u4e0d\u540c\u6709\u65f6\u5019\u751a\u81f3\u5b8c\u5168\u4e0d\u517c\u5bb9\u3002\n\n\u56e0\u6b64npm\u6700\u65b0\u7684\u7248\u672c\u5c31\u5f00\u59cb\u63d0\u4f9b\u81ea\u52a8\u751f\u6210package-lock.json\u529f\u80fd\uff0c\u4e3a\u7684\u662f\u8ba9\u5f00\u53d1\u8005\u77e5\u9053\u53ea\u8981\u4f60\u4fdd\u5b58\u4e86\u6e90\u6587\u4ef6\uff0c\u5230\u4e00\u4e2a\u65b0\u7684\u673a\u5668\u4e0a\u3001\u6216\u8005\u65b0\u7684\u4e0b\u8f7d\u6e90\uff0c\u53ea\u8981\u6309\u7167\u8fd9\u4e2apackage-lock.json\u6240\u6807\u793a\u7684\u5177\u4f53\u7248\u672c\u4e0b\u8f7d\u4f9d\u8d56\u5e93\u5305\uff0c\u5c31\u80fd\u786e\u4fdd\u6240\u6709\u5e93\u5305\u4e0e\u4f60\u4e0a\u6b21\u5b89\u88c5\u7684\u5b8c\u5168\u4e00\u6837\u3002<\/pre>\n\n\n\n<p>\u539f\u6765package.json\u6587\u4ef6\u53ea\u80fd\u9501\u5b9a\u5927\u7248\u672c\uff0c\u4e5f\u5c31\u662f\u7248\u672c\u53f7\u7684\u7b2c\u4e00\u4f4d\uff0c\u5e76\u4e0d\u80fd\u9501\u5b9a\u540e\u9762\u7684\u5c0f\u7248\u672c\uff0c\u4f60\u6bcf\u6b21npm install\u90fd\u662f\u62c9\u53d6\u7684\u8be5\u5927\u7248\u672c\u4e0b\u7684\u6700\u65b0\u7684\u7248\u672c\uff0c\u4e3a\u4e86\u7a33\u5b9a\u6027\u8003\u8651\u6211\u4eec\u51e0\u4e4e\u662f\u4e0d\u6562\u968f\u610f\u5347\u7ea7\u4f9d\u8d56\u5305\u7684\uff0c\u8fd9\u5c06\u5bfc\u81f4\u591a\u51fa\u6765\u5f88\u591a\u5de5\u4f5c\u91cf\uff0c\u6d4b\u8bd5\/\u9002\u914d\u7b49\uff0c\u6240\u4ee5package-lock.json\u6587\u4ef6\u51fa\u6765\u4e86\uff0c\u5f53\u4f60\u6bcf\u6b21\u5b89\u88c5\u4e00\u4e2a\u4f9d\u8d56\u7684\u65f6\u5019\u5c31\u9501\u5b9a\u5728\u4f60\u5b89\u88c5\u7684\u8fd9\u4e2a\u7248\u672c\u3002<\/p>\n\n\n\n<p>\u90a3\u5982\u679c\u6211\u4eec\u5b89\u88c5\u65f6\u7684\u5305\u6709bug\uff0c\u540e\u9762\u9700\u8981\u66f4\u65b0\u600e\u4e48\u529e\uff1f<\/p>\n\n\n\n<p>\u5728\u4ee5\u524d\u53ef\u80fd\u5c31\u662f\u76f4\u63a5\u6539package.json\u91cc\u9762\u7684\u7248\u672c\uff0c\u7136\u540e\u518dnpm install\u4e86\uff0c\u4f46\u662f5\u7248\u672c\u540e\u5c31\u4e0d\u652f\u6301\u8fd9\u6837\u505a\u4e86\uff0c\u56e0\u4e3a\u7248\u672c\u5df2\u7ecf\u9501\u5b9a\u5728package-lock.json\u91cc\u4e86\uff0c\u6240\u4ee5\u6211\u4eec\u53ea\u80fdnpm install xxx@x.x.x \u8fd9\u6837\u53bb\u66f4\u65b0\u6211\u4eec\u7684\u4f9d\u8d56\uff0c\u7136\u540epackage-lock.json\u4e5f\u80fd\u968f\u4e4b\u66f4\u65b0\u3002<\/p>\n\n\n\n<p>\u5047\u5982\u6211\u5df2\u7ecf\u5b89\u88c5\u4e86jquery 2.1.4\u8fd9\u4e2a\u7248\u672c\uff0c\u4ecegit\u66f4\u65b0\u4e86package.json\u548cpackage-lock.json\uff0c\u6211npm install\u80fd\u8986\u76d6\u6389node_modules\u91cc\u9762\u7684\u4f9d\u8d56\u5417?<\/p>\n\n\n\n<p>\u5176\u5b9e\u6211\u4e5f\u6709\u8fd9\u4e2a\u7591\u95ee\uff0c\u6240\u4ee5\u505a\u4e86\u6d4b\u8bd5\uff0c\u5728\u76f4\u63a5\u66f4\u65b0package.json\u548cpackage-loc.json\u8fd9\u4e24\u4e2a\u6587\u4ef6\u540e\uff0cnpm install\u662f\u53ef\u4ee5\u76f4\u63a5\u8986\u76d6\u6389\u539f\u5148\u7684\u7248\u672c\u7684\uff0c\u6240\u4ee5\u5728\u534f\u4f5c\u5f00\u53d1\u65f6\uff0c\u8fd9\u4e24\u4e2a\u6587\u4ef6\u5982\u679c\u6709\u66f4\u65b0\uff0c\u4f60\u7684\u5f00\u53d1\u73af\u5883\u5e94\u8be5npm install\u4e00\u4e0b\u624d\u5bf9\u3002<\/p>\n\n\n\n<p id=\"package-lockjson\u4f7f\u7528\u5efa\u8bae\"><strong>package-lock.json\u4f7f\u7528\u5efa\u8bae<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5f00\u53d1\u7cfb\u7edf\u5e94\u7528\u65f6\uff0c\u5efa\u8bae\u628a package-lock.json \u6587\u4ef6\u63d0\u4ea4\u5230\u4ee3\u7801\u7248\u672c\u4ed3\u5e93\uff0c\u4ece\u800c\u4fdd\u8bc1\u6240\u6709\u56e2\u961f\u5f00\u53d1\u8005\u4ee5\u53ca CI \u73af\u8282\u53ef\u4ee5\u5728\u6267\u884c npm install \u65f6\u5b89\u88c5\u7684\u4f9d\u8d56\u7248\u672c\u90fd\u662f\u4e00\u81f4\u7684\u3002<\/p>\n\n\n\n<p>\u5728\u5f00\u53d1\u4e00\u4e2a npm\u5305 \u65f6\uff0c\u4f60\u7684 npm\u5305 \u662f\u9700\u8981\u88ab\u5176\u4ed6\u4ed3\u5e93\u4f9d\u8d56\u7684\uff0c\u7531\u4e8e\u4e0a\u9762\u6211\u4eec\u8bb2\u5230\u7684\u6241\u5e73\u5b89\u88c5\u673a\u5236\uff0c\u5982\u679c\u4f60\u9501\u5b9a\u4e86\u4f9d\u8d56\u5305\u7248\u672c\uff0c\u4f60\u7684\u4f9d\u8d56\u5305\u5c31\u4e0d\u80fd\u548c\u5176\u4ed6\u4f9d\u8d56\u5305\u5171\u4eab\u540c\u4e00 semver \u8303\u56f4\u5185\u7684\u4f9d\u8d56\u5305\uff0c\u8fd9\u6837\u4f1a\u9020\u6210\u4e0d\u5fc5\u8981\u7684\u5197\u4f59\u3002\u6240\u4ee5\u6211\u4eec\u4e0d\u5e94\u8be5\u628apackage-lock.json \u6587\u4ef6\u53d1\u5e03\u51fa\u53bb\uff08 npm \u9ed8\u8ba4\u4e5f\u4e0d\u4f1a\u628a package-lock.json \u6587\u4ef6\u53d1\u5e03\u51fa\u53bb\uff0c\u5f53\u7136\u5982\u679c\u975e\u8981\u7528package-lock.json\u4e5f\u662f\u53ef\u4ee5\u7684\uff09\u3002<\/p>\n\n\n\n<p><strong>\u9644\uff1anpm \u62c9\u5305\u673a\u5236<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-1024x512.png\" alt=\"\" class=\"wp-image-12869\" width=\"601\" height=\"301\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-1024x512.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-300x150.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-768x384.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-1536x767.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-2048x1023.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-830x415.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-230x115.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-350x175.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-6-480x240.png 480w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">1. \u68c0\u67e5\u5e76\u83b7\u53d6 npm \u914d\u7f6e\uff0c\u8fd9\u91cc\u7684\u4f18\u5148\u7ea7\u4e3a\uff1a\u9879\u76ee\u7ea7\u7684 .npmrc \u6587\u4ef6 > \u7528\u6237\u7ea7\u7684 .npmrc \u6587\u4ef6> \u5168\u5c40\u7ea7\u7684 .npmrc \u6587\u4ef6 > npm \u5185\u7f6e\u7684 .npmrc \u6587\u4ef6\u3002\n2. \u68c0\u67e5\u9879\u76ee\u4e2d\u662f\u5426\u6709 package-lock.json \u6587\u4ef6\u3002\n3. 3.1 \u5982\u679c\u6709\uff0c\u5219\u68c0\u67e5 package-lock.json \u548c package.json \u4e2d\u58f0\u660e\u7684\u4f9d\u8d56\u662f\u5426\u4e00\u81f4\uff1a\n         a: \u4e00\u81f4\uff0c\u76f4\u63a5\u4f7f\u7528 package-lock.json \u4e2d\u7684\u4fe1\u606f\uff0c\u4ece\u7f13\u5b58\u6216\u7f51\u7edc\u8d44\u6e90\u4e2d\u52a0\u8f7d\u4f9d\u8d56\uff1b\n         b: \u4e0d\u4e00\u81f4\uff0c\u6309\u7167 npm \u7248\u672c\u8fdb\u884c\u5904\u7406\uff08\u4e0d\u540c npm \u7248\u672c\u5904\u7406\u4f1a\u6709\u4e0d\u540c\uff0c\u5177\u4f53\u5904\u7406\u65b9\u5f0f\u5982\u56fe\u6240\u793a\uff09\u3002\n   3.2 \u5982\u679c\u6ca1\u6709\uff0c\u5219\u6839\u636e package.json \u9012\u5f52\u6784\u5efa\u4f9d\u8d56\u6811\u3002\u7136\u540e\u6309\u7167\u6784\u5efa\u597d\u7684\u4f9d\u8d56\u6811\u4e0b\u8f7d\u5b8c\u6574\u7684\u4f9d\u8d56\u8d44\u6e90\uff0c\u5728\u4e0b\u8f7d\u65f6\u5c31\u4f1a\u68c0\u67e5\u662f\u5426\u5b58\u5728\u76f8\u5173\u8d44\u6e90\u7f13\u5b58\uff1a\n        a: \u5b58\u5728\uff0c\u5219\u5c06\u7f13\u5b58\u5185\u5bb9\u89e3\u538b\u5230 node_modules \u4e2d\uff1b\n        b: \u5426\u5219\u5c31\u5148\u4ece npm \u8fdc\u7a0b\u4ed3\u5e93\u4e0b\u8f7d\u5305\uff0c\u6821\u9a8c\u5305\u7684\u5b8c\u6574\u6027\uff0c\u5e76\u6dfb\u52a0\u5230\u7f13\u5b58\uff0c\u540c\u65f6\u89e3\u538b\u5230 node_modules\u3002\n4. \u751f\u6210 package-lock.json\u3002    \n<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8-1024x573.png\" alt=\"\" class=\"wp-image-12874\" width=\"564\" height=\"316\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8-1024x573.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8-300x168.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8-768x430.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8-830x464.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8-230x129.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8-350x196.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8-480x269.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/10\/\u56fe\u7247-8.png 1144w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/www.cnblogs.com\/yalong\/p\/15013880.html pac [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12861"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12861"}],"version-history":[{"count":4,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12861\/revisions"}],"predecessor-version":[{"id":12876,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12861\/revisions\/12876"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}