{"id":9881,"date":"2023-03-13T17:08:27","date_gmt":"2023-03-13T09:08:27","guid":{"rendered":"http:\/\/123.57.164.21\/?p=9881"},"modified":"2023-03-13T17:08:27","modified_gmt":"2023-03-13T09:08:27","slug":"package-json%e4%b8%ad%e7%9a%84%e5%bc%80%e5%8f%91%e4%be%9d%e8%b5%96dependencies%e5%92%8c%e7%94%9f%e4%ba%a7%e4%be%9d%e8%b5%96devdependencies%e5%88%b0%e5%ba%95%e6%9c%89%e4%bd%95%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=9881","title":{"rendered":"package.json\u4e2d\u7684\u5f00\u53d1\u4f9d\u8d56dependencies\u548c\u751f\u4ea7\u4f9d\u8d56devDependencies\u5230\u5e95\u6709\u4f55\u533a\u522b"},"content":{"rendered":"\n<p><strong>\u89e3\u91ca\u4e00\u4e0b\u533a\u522b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u9996\u5148\uff0c\u4e24\u4e2a\u90fd\u662f\u6b64\u9879\u76ee\u7684\u4f9d\u8d56:<\/p>\n\n\n\n<ul><li>1\u3001dependencies \u662f\u53d1\u5e03\u5230\u751f\u4ea7\u73af\u5883\u7684\uff0c\u800c devDependencies \u91cc\u9762\u7684\u63d2\u4ef6\u53ea\u7528\u4e8e\u5f00\u53d1\u73af\u5883\uff0c\u4e0d\u7528\u4e8e\u751f\u4ea7\u73af\u5883\u3002<\/li><li>2\u3001dependencies \u662f\u9879\u76ee\u6b63\u5e38\u8fd0\u884c\u6240\u9700\u8981\u7684\u4f9d\u8d56\uff0c\u800cdevDependencies\u5219\u662f\u5f00\u53d1\u8005\u5f00\u53d1\u65f6\u6574\u4e2a\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\uff08\u5982\u4f1a\u6709\u4e00\u4e9b\u6d4b\u8bd5\u4f9d\u8d56\u4e4b\u7c7b\u7684\uff09\u3002<\/li><\/ul>\n\n\n\n<p>\u5176\u6b21\uff0c\u533a\u522b\u662f\uff1a<\/p>\n\n\n\n<ul><li>1\u3001\u4f7f\u7528 &#8211;save-dev \u5b89\u88c5\u7684\u63d2\u4ef6\uff0c\u4f1a\u88ab\u5199\u5165\u5230 devDependencies \u5bf9\u8c61\u91cc\u9762\u53bb\uff1b<\/li><li>2\u3001\u4f7f\u7528 &#8211;save \u5b89\u88c5\u7684\u63d2\u4ef6\uff0c\u4f1a\u88ab\u5199\u5165\u5230 dependencies \u5bf9\u8c61\u91cc\u9762\u53bb\u3002<\/li><\/ul>\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 *****  \/\/\u4f1a\u4e0b\u8f7d\u5230node_modules\u76ee\u5f55\u4e2d\uff0c\u5e76\u4fee\u6539package.json\uff08dependencies\u4e2d\u4f1a\u589e\u52a0\uff09 \n npm install --save-dev *** \/\/\u4f1a\u4e0b\u8f7d\u5230node_modules\u76ee\u5f55\u4e2d\uff0c\u5e76\u4fee\u6539package.json\uff08devDependencies\u4e2d\u4f1a\u589e\u52a0\uff09 \n npm install **** \/\/ \u4f1a\u4e0b\u8f7d\u5230node_modules\u76ee\u5f55\u4e2d\uff0c\u4e0d\u4f1a\u4fee\u6539package.json\n npm install ***** --save  \/\/\u4f1a\u4e0b\u8f7d\u5230node_modules\u76ee\u5f55\u4e2d\uff0c\u5e76\u4fee\u6539package.json\uff08dependencies\u4e2d\u4f1a\u589e\u52a0\uff09 \n npm install \/\/\u4f1a\u9ed8\u8ba4\u5b89\u88c5\u4e24\u79cd\u4f9d\u8d56```<\/pre>\n\n\n\n<p><strong>Angular\u7684\u4f8b\u5b50\uff1a<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5728\u5f00\u53d1Angular\u9879\u76ee\u7684\u65f6\u5019\uff0c\u9700\u8981\u5728package.json\u6587\u4ef6\u91cc\u6807\u8bb0\u672c\u9879\u76ee\u9700\u8981\u54ea\u4e9bnpm\u4f9d\u8d56\u5305\uff0c\u5176\u4e2d\u5c31\u4f1a\u6709<code>dependencies<\/code>\u548c<code>devDependencies<\/code>\u4e24\u4e2a\u5b57\u6bb5\uff1b\u90a3\u4e48\u5b83\u4eec\u5206\u522b\u4ee3\u8868\u4ec0\u4e48\uff0c\u53c8\u6709\u4ec0\u4e48\u533a\u522b\u5462\uff1f<\/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    \"@angular\/common\": \"2.0.0\",\n    \"@angular\/compiler\": \"2.0.0\",\n    \"@angular\/core\": \"2.0.0\",\n    \"@angular\/forms\": \"2.0.0\",\n    \"@angular\/http\": \"2.0.0\",\n    \"@angular\/platform-browser\": \"2.0.0\",\n    \"@angular\/platform-browser-dynamic\": \"2.0.0\",\n    \"@angular\/router\": \"3.0.0\",\n    \"@angular\/upgrade\": \"2.0.0\",\n    \"core-js\": \"^2.4.1\",\n    \"reflect-metadata\": \"^0.1.3\",\n    \"rxjs\": \"5.0.0-beta.12\",\n    \"systemjs\": \"0.19.27\",\n    \"zone.js\": \"^0.6.23\",\n    \"angular2-in-memory-web-api\": \"0.0.20\",\n    \"bootstrap\": \"^3.3.6\"\n  },\n  \"devDependencies\": {\n    \"concurrently\": \"^2.2.0\",\n    \"lite-server\": \"^2.2.2\",\n    \"typescript\": \"^2.3.4\",\n    \"typings\": \"^1.3.2\"\n  }\n<\/pre>\n\n\n\n<p>\u4ece\u540d\u5b57\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u51fa\uff0c<code>devDependencies<\/code>\u662f\u7528\u4e8e\u5728\u5f00\u53d1\u73af\u5883\u4e0b\u4f9d\u8d56\u7684\u6a21\u5757\uff0c\u800c<code>dependencies<\/code>\u5c31\u662f\u65e0\u8bba\u5f00\u53d1\u73af\u5883\u8fd8\u662f\u751f\u4ea7\u73af\u5883\u90fd\u9700\u8981\u7684\u4f9d\u8d56\u6a21\u5757\u3002<\/p>\n\n\n\n<p>\u4e3e\u4e2a\u4e0a\u9762\u4e2d\u4ee3\u7801\u7684\u6817\u5b50\uff0c\u4f9d\u8d56concurrently\uff0clite-server\uff0ctypescript\u548ctypings\u53ea\u662f\u6211\u4eec\u5728\u5f00\u53d1\u4e2d\u9700\u8981\u4f7f\u7528\u7684\u5305\uff0c\u4e0a\u7ebf\u4ee5\u540e\u9879\u76ee\u7684\u8fd0\u884c\u5c31\u4e0d\u9700\u8981\u4e86\uff0c\u56e0\u6b64\u5c31\u653e\u5728<code>devDependencies<\/code>\u4f9d\u8d56\u91cc\uff1b\u800c<code>dependencies<\/code>\u91cc\u90a3\u4e9b\u4f9d\u8d56\uff1aangular\/XXXX\uff0ccore-js\uff0creflect-metadata\uff0crxjs\uff0csystemjs\uff0czone.js\uff0cangular2-in-memory-web-api\uff0cbootstrap \u5219\u662f\u6211\u4eec\u6574\u4e2a\u9879\u76ee\u8fd0\u884c\u65f6\u5019\u5c31\u9700\u8981\u7684\uff0c\u56e0\u6b64\u653e\u5728<code>dependencies<\/code>\u91cc\u3002<\/p>\n\n\n\n<p>\u800c\u5f53\u56e2\u961f\u91cc\u5176\u4ed6\u4ebaclone\u8fd9\u4e2a\u9879\u76ee\u8fdb\u884c\u5f00\u53d1\u8c03\u8bd5\u7684\u65f6\u5019\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7<code>npm install<\/code>\u64cd\u4f5c\u4e00\u952e\u5b89\u88c5\u8fd9\u4e24\u4e2a\u76ee\u5f55\u4e0b\u6240\u6709\u7684\u4f9d\u8d56\uff0c\u800c\u4e0d\u7528\u53bb\u4e00\u884c\u884c\u627e\u90fd\u5728\u6587\u4ef6\u4e2d\u5f15\u7528\u4e86\u54ea\u4e9b\u4f9d\u8d56\u3002<\/p>\n\n\n\n<p>\u6ce8\uff1a\u5982\u679c\u5176\u4ed6\u4eba\u8f93\u5165\u7684\u662f<code>npm install --production<\/code> \u6307\u4ee4\uff0c\u90a3\u4e48\u5c31\u53ea\u4f1a\u5b89\u88c5dependencies \u76ee\u5f55\u4e0b\u7684\u4f9d\u8d56\uff1b\u8fd9\u4e2a\u64cd\u4f5c\u6bd4\u8f83\u5c11\u89c1\uff0c\u4e00\u822c\u5728\u4e00\u4e9b\u670d\u52a1\u7aef\u81ea\u52a8\u6784\u5efa\u7684\u8fc7\u7a0b\u4e2d\u6216\u8005\u5728\u4e00\u4e9b\u7279\u6b8a\u7684\u9700\u6c42\u4e0b\uff0c\u4f1a\u7528\u5230\u8fd9\u4e2a\u6307\u4ee4\u3002<\/p>\n\n\n\n<p><strong>\u6211\u7684\u8bef\u533a<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6700\u8fd1\u5728\u5b66\u4e60webpack\uff0c\u4e2d\u95f4\u53d1\u73b0\u4e00\u4e2a\u6709\u8da3\u7684\u95ee\u9898\uff0c\u5bf9\u4e8e\u5f00\u53d1\u4f9d\u8d56\u548c\u751f\u4ea7\u4f9d\u8d56\uff0c\u6478\u7d22\u4e2d\u9047\u5230\u4e86\u4e24\u79cd\u4e0d\u540c\u7684\u8bf4\u6cd5\uff0c\u4e00\u79cd\u662f\u8981\u4e25\u683c\u533a\u5206\uff0c\u4e00\u79cd\u662f\u5199\u5728\u54ea\u91cc\u90fd\u4e00\u6837\uff0c\u6253\u5305\u51fa\u6765\u7684\u662f\u4e00\u6837\u7684\u3002\u4e8e\u662f\u67e5\u770b\u4e86\u5f88\u591a\u535a\u5ba2\uff0c\u5bf9\u4e8e\u7ea0\u7ed3\u4e86\u597d\u51e0\u5929\u7684\u95ee\u9898\uff0c\u505a\u4e00\u4e0b\u603b\u7ed3\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u8bf4 devDependencies\u662f\u5f00\u53d1\u4f9d\u8d56 \uff0c dependencies\u662f\u751f\u4ea7\u4f9d\u8d56\u3002\u6211\u4e00\u76f4\u8ba4\u4e3a\u6211\u4eec\u5728npm run build \u7684\u65f6\u5019\u5c31\u76f4\u63a5\u7528\u7684\u662f\u751f\u4ea7\u4f9d\u8d56\uff0c\u5728npm run serve\u7684\u65f6\u5019\u7528\u7684\u5c31\u662f\u5f00\u53d1\u4f9d\u8d56\u3002\u6bd4\u5982\u5efa\u8bae\u6211\u4eec\u628a\u5bf9\u4ee3\u7801\u5904\u7406\u7684\u538b\u7f29\uff0c\u5408\u5e76\u7b49\u7b49webpack\u7684\u4e00\u7cfb\u5217\u64cd\u4f5c\u5e94\u8be5\u653e\u5728\u5f00\u53d1\u4f9d\u8d56\u91cc\u9762\u3002\u628a\u771f\u6b63\u9875\u9762\u7528\u5230\u7684\u6bd4\u5982jquery\u3001vue\u3001vue-router\u7b49\u7b49\u653e\u5230\u751f\u4ea7\u4f9d\u8d56\u91cc\u9762\u3002\u4e8e\u662f\u6211\u5c31\u6709\u4e00\u4e2a\u7591\u95ee\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-54.png\" alt=\"\" class=\"wp-image-9882\" width=\"164\" height=\"258\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-54.png 470w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-54-191x300.png 191w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-54-230x362.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-54-350x551.png 350w\" sizes=\"(max-width: 164px) 100vw, 164px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u5982\u679cnpm run serve \u53ea\u7528\u5f00\u53d1\u4f9d\u8d56\uff0c\u90a3\u5f00\u53d1\u73af\u5883\u4e5f\u9700\u8981vue\u7b49\u8fd9\u4e9b\u4e1c\u897f\u554a\uff1f\u600e\u4e48\u505a\u5230\u53ef\u4ee5\u7528\u7684\u5462\uff1f\u5177\u4f53\u600e\u4e48\u6253\u5305\u5462\uff1f<\/strong>\u7136\u540e\u6211\u505a\u4e86\u4e00\u4e2a\u5b9e\u9a8c\uff0c\u6211\u628apackage.json\u91cc\u9762\u7684devDependencies\u548cdependencies\u90fd\u5220\u9664\u6389\uff0c\u518d\u8fdb\u884c\u5f00\u53d1\u548c\u53d1\u5e03\u6d4b\u8bd5\u3002\u53d1\u73b0\u5b8c\u5168\u4e0d\u53d7\u5f71\u54cd\u3002\u8fd8\u53ef\u4ee5\u5b8c\u6574\u7684\u6b63\u5e38\u6253\u5305\u3002\u540e\u6765\u6211\u624d\u60f3\u660e\u767d\uff0c\u8fd9\u4e2a<strong>\u5f00\u53d1\u4f9d\u8d56\u548c\u751f\u4ea7\u4f9d\u8d56\u53ea\u662f\u9488\u5bf9\u4e0enpm install\u3002npm install\u7684\u65f6\u5019\u4f1a\u628a\u8fd9\u91cc\u9762\u7684\u90fd\u4e0b\u8f7d\u4e0b\u6765\uff0c\u7136\u540e\u505a\u533a\u5206\u3002\u800cwebpack\u771f\u6b63\u6253\u5305\u7684\u65f6\u5019\uff0c\u662f\u57fa\u4e8e\u9875\u9762\u4e0a\u6309\u9700\u6253\u5305\u7684\uff0c\u7528\u5230\u4ec0\u4e48\u6253\u5305\u4ec0\u4e48\uff0c\u53ea\u8981\u6211\u4eec\u7684node_modules\u91cc\u9762\u6709\u5c31\u53ef\u4ee5\u3002\u6211\u7684\u8bef\u533a\u662f\u628a\u8fd9\u4fe9\u4e2a\u8fc7\u7a0b\u6df7\u6dc6\u4e86\u3002\u6240\u4ee5\u5728SPA\u5355\u9875\u5e94\u7528\u4e2d\uff0c\u653e\u5728\u54ea\u91cc\u90fd\u4e00\u6837\u3002\u552f\u4e00\u7684\u662f\u4e25\u683c\u653e\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u4e00\u773c\u770b\u6e05\u695a\u8fd9\u4e9b\u63d2\u4ef6\u5927\u6982\u7684\u7528\u5904\u3002<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u91ca\u4e00\u4e0b\u533a\u522b \u9996\u5148\uff0c\u4e24\u4e2a\u90fd\u662f\u6b64\u9879\u76ee\u7684\u4f9d\u8d56: 1\u3001dependencies \u662f\u53d1\u5e03\u5230\u751f\u4ea7\u73af\u5883\u7684\uff0c\u800c devDep [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/9881"}],"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=9881"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/9881\/revisions"}],"predecessor-version":[{"id":9884,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/9881\/revisions\/9884"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}