{"id":1420,"date":"2024-11-10T11:33:00","date_gmt":"2024-11-10T03:33:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1420\/"},"modified":"2024-11-10T11:33:00","modified_gmt":"2024-11-10T03:33:00","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e4%b8%8d%e5%ae%89%e8%a3%85-angular-cli-%e7%9a%84%e6%83%85%e5%86%b5%e4%b8%8b%e5%88%9b%e5%bb%ba-angular-%e9%a1%b9%e7%9b%ae%e7%9a%84%e7%89%b9%e5%ae%9a%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1420\/","title":{"rendered":"\u5982\u4f55\u5728\u4e0d\u5b89\u88c5 Angular CLI \u7684\u60c5\u51b5\u4e0b\u521b\u5efa Angular \u9879\u76ee\u7684\u7279\u5b9a\u7248\u672c"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173042913597810.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728\u4e0d\u5b89\u88c5 Angular CLI \u7684\u60c5\u51b5\u4e0b\u521b\u5efa Angular \u9879\u76ee\u7684\u7279\u5b9a\u7248\u672c\u63d2\u56fe\" alt=\"\u5982\u4f55\u5728\u4e0d\u5b89\u88c5 Angular CLI \u7684\u60c5\u51b5\u4e0b\u521b\u5efa Angular \u9879\u76ee\u7684\u7279\u5b9a\u7248\u672c\u63d2\u56fe\" \/><\/p>\n<p>\u60a8\u662f\u5426\u4f7f\u7528 angular \u5e76\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u7684 angular \u7248\u672c\u8bbe\u7f6e\u9879\u76ee\uff1f\u8fd9\u662f\u4e3a\u7279\u5b9a\u7248\u672c\u521b\u5efa angular \u9879\u76ee\u7684\u7b80\u5355\u6307\u5357\uff0c\u65e0\u8bba\u662f\u5426\u4f7f\u7528 angular cli\uff01<\/p>\n<h2> \u4e3a\u4ec0\u4e48\u4f7f\u7528\u7279\u5b9a\u7684 angular \u7248\u672c\uff1f <\/h2>\n<p>\u5728\u5904\u7406\u591a\u4e2a angular \u9879\u76ee\u65f6\uff0c\u6709\u65f6\u60a8\u9700\u8981\u9501\u5b9a\u7279\u5b9a\u7248\u672c\u3002\u4e5f\u8bb8\u60a8\u7684\u9879\u76ee\u4f9d\u8d56\u4e8e\u4ec5\u5728\u7279\u5b9a\u7248\u672c\u4e2d\u53ef\u7528\u7684\u67d0\u4e9b\u529f\u80fd\uff0c\u6216\u8005\u53ef\u80fd\u9700\u8981\u4e0e\u9057\u7559\u4ee3\u7801\u5e93\u517c\u5bb9\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u521b\u5efa\u5177\u6709\u7279\u5b9a angular \u7248\u672c\u7684\u9879\u76ee &#8211; \u65e0\u8bba\u60a8\u662f\u5426\u4f7f\u7528 cli\uff01<\/p>\n<hr>\n<h2> 1. \u521b\u5efa angular \u9879\u76ee<em>\u4e0d<\/em>\u5b89\u88c5 angular cli <\/h2>\n<p>\u60a8\u662f\u5426\u77e5\u9053\u65e0\u9700\u5b89\u88c5 cli \u5373\u53ef\u521d\u59cb\u5316\u7279\u5b9a\u7248\u672c\u7684 angular \u9879\u76ee\uff1f\u8ba9\u6211\u4eec\u770b\u770b\u8bed\u6cd5\u548c\u793a\u4f8b\u3002<\/p>\n<h3> \u53e5\u6cd5 <\/h3>\n<pre>npm init @angular@&lt;version&gt; &lt;project-name&gt;\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06  \u66ff\u6362\u4e3a\u60a8\u60f3\u8981\u7684 angular \u7248\u672c\uff0c\u5e76\u5c06  \u66ff\u6362\u4e3a\u60a8\u7684\u9879\u76ee\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a sampleapp \u7684 angular 16 \u9879\u76ee\uff0c\u60a8\u53ef\u4ee5\u8fd0\u884c\uff1a  <\/p>\n<h3> \u4f8b\u5b50 <\/h3>\n<pre>npm init @angular@16 sampleapp\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u57fa\u672c\u7684 angular \u9879\u76ee\uff0c\u65e0\u9700\u5168\u5c40\u5b89\u88c5 angular cli\u3002\u5982\u679c\u60a8\u60f3\u907f\u514d\u5b89\u88c5\u989d\u5916\u7684\u5de5\u5177\u6216\u8005\u5728\u53d7\u9650\u7684\u73af\u5883\u4e2d\u5de5\u4f5c\uff0c\u5b83\u4f1a\u5f88\u65b9\u4fbf\u3002<\/p>\n<h4> \u5176\u4ed6\u4f8b\u5b50 <\/h4>\n<ul>\n<li>\n<p><strong>\u540d\u4e3alegacyapp\u7684angular 13\u9879\u76ee\uff1a<\/strong><\/p>\n<pre>npm init @angular@13 legacyapp\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/li>\n<\/ul>\n<p>\u6b64\u547d\u4ee4\u76f4\u63a5\u62c9\u53d6\u5fc5\u8981\u7684 angular \u7248\u672c\uff0c\u8bbe\u7f6e\u7279\u5b9a\u4e8e\u8be5\u7248\u672c\u7684\u9879\u76ee\u7ed3\u6784\u548c\u4f9d\u8d56\u9879\u3002<\/p>\n<hr>\n<h2> 2. \u4f7f\u7528 <em> angular cli \u521b\u5efa angular \u9879\u76ee\u7684\u7279\u5b9a\u7248\u672c <\/em> <\/h2>\n<p>\u5982\u679c\u60a8\u66f4\u559c\u6b22\u4f7f\u7528 angular cli\uff0c\u60a8\u4ecd\u7136\u53ef\u4ee5\u4e3a\u7279\u5b9a\u7248\u672c\u521b\u5efa\u9879\u76ee\uff0c\u800c\u65e0\u9700\u6c38\u4e45\u5b89\u88c5 cli\u3002\u4f7f\u7528 npx \u76f4\u63a5\u8fd0\u884c cli\uff0c\u6307\u5b9a\u60a8\u7684\u7248\u672c\u3002 <\/p>\n<p> \u53e5\u6cd5 <\/p>\n<h3>\n<pre>npx -p @angular\/cli@&lt;version&gt; ng new &lt;project-name&gt;\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/h3>\n<p>\u6b64\u547d\u4ee4\u4f7f\u7528 npx \u4e34\u65f6\u8fd0\u884c\u6307\u5b9a\u7684 cli \u7248\u672c\uff0c\u521b\u5efa\u9002\u5408\u8be5 angular \u7248\u672c\u7684\u9879\u76ee\u3002 <\/p>\n<p> \u4f8b\u5b50 <\/p>\n<h3>\n<pre>npx -p @angular\/cli@13 ng new demoApp\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/h3>\n<p>\u6b64\u547d\u4ee4\u4f1a\u4f7f\u7528 angular cli \u7248\u672c 13 \u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u5373\u4f7f\u60a8\u5728\u5168\u5c40\u5b89\u88c5\u4e86\u4e0d\u540c\u7684 angular cli \u7248\u672c\u4e5f\u662f\u5982\u6b64\u3002 <\/p>\n<p> \u4f7f\u7528 npx \u7684\u4f18\u70b9\uff1a <\/p>\n<h4> <\/h4>\n<ul>\n<li>\u65e0\u9700\u6c38\u4e45\u5b89\u88c5<strong>\uff1a\u4e00\u6b21\u6027\u4e0b\u8f7d\u6307\u5b9a\u7684cli\u7248\u672c\uff0c\u8282\u7701\u7a7a\u95f4\u5e76\u907f\u514d\u6f5c\u5728\u7684\u7248\u672c\u51b2\u7a81\u3002<\/strong> <\/li>\n<li>\u8f7b\u677e\u5207\u6362\u7248\u672c<strong>\uff1a\u60a8\u53ef\u4ee5\u5728\u4e0d\u540c\u9879\u76ee\u7684\u7248\u672c\u4e4b\u95f4\u5feb\u901f\u5207\u6362\uff0c\u800c\u65e0\u9700\u7ba1\u7406\u591a\u4e2a\u5168\u5c40 cli \u5b89\u88c5\u3002<\/strong> <\/li>\n<\/ul>\n<hr>\n<p> \u4f55\u65f6\u9009\u62e9 cli \u4e0e\u975e cli \u65b9\u6cd5 <\/p>\n<h2> <\/h2>\n<p> \u6ca1\u6709 cli <\/p>\n<h3> <\/h3>\n<ul>\n  \u5f53\u60a8\u60f3\u8981\u6700\u5c11\u7684\u8bbe\u7f6e\u65f6 <\/p>\n<li> <\/li>\n<p>\u5728\u6ca1\u6709\u5168\u5c40 angular cli \u5b89\u88c5\u7684\u53d7\u9650\u73af\u5883\u4e2d\u5de5\u4f5c\u65f6 <\/p>\n<li> <\/li>\n<\/ul>\n<p> \u4f7f\u7528 cli <\/p>\n<h3> <\/h3>\n<ul>\n  \u5f53\u60a8\u9700\u8981\u5229\u7528 cli \u547d\u4ee4\u548c\u539f\u7406\u56fe\u65f6 <\/p>\n<li> <\/li>\n<p>\u8bbe\u7f6e\u529f\u80fd\u9f50\u5168\u7684 angular \u5de5\u4f5c\u533a\u65f6 <\/p>\n<li> <\/li>\n<\/ul>\n<hr>\n<p> \u603b\u7ed3 <\/p>\n<h2> <\/h2>\n<p>\u65e0\u8bba\u60a8\u9009\u62e9\u4f7f\u7528\u8fd8\u662f\u4e0d\u4f7f\u7528 cli\uff0cangular \u7684 npm init \u548c npx \u7684\u7075\u6d3b\u6027\u90fd\u53ef\u4ee5\u8ba9\u60a8\u8f7b\u677e\u7ba1\u7406\u8de8\u4e0d\u540c\u7248\u672c\u7684\u9879\u76ee\u3002\u56e0\u6b64\uff0c\u4e0b\u6b21\u60a8\u9700\u8981\u542f\u52a8\u7279\u5b9a\u7684 angular \u7248\u672c\u9879\u76ee\u65f6\uff0c\u60a8\u5c06\u786e\u5207\u5730\u77e5\u9053\u5982\u4f55\u6267\u884c\u6b64\u64cd\u4f5c\uff0c\u800c\u65e0\u9700\u4e3a cli \u5b89\u88c5\u800c\u70e6\u607c\uff01 <\/p>\n<p> \u5feb\u901f\u547d\u4ee4\u56de\u987e <\/p>\n<h3> <\/h3>\n<table>\n<thead>\n<tr>\n<th>angular version<\/th>\n<th>without cli<\/th>\n<th>with cli<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>16<\/td>\n<td>npm init @angular@16 sampleapp<\/td>\n<td>npx -p @angular\/cli@16 ng new sampleapp<\/td>\n<\/tr>\n<tr>\n<td>13<\/td>\n<td>npm init @angular@13 legacyapp<\/td>\n<td>npx -p @angular\/cli@13 ng new demoapp<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr>\n<p>\u5c31\u662f\u8fd9\u6837\uff01\u5e0c\u671b\u60a8\u53d1\u73b0\u672c\u6307\u5357\u5bf9\u60a8\u7684 angular \u9879\u76ee\u6709\u6240\u5e2e\u52a9\u3002\u5982\u679c\u60a8\u5bf9\u4f7f\u7528\u7279\u5b9a angular \u7248\u672c\u6709\u4efb\u4f55\u7591\u95ee\u6216\u6280\u5de7\uff0c\u8bf7\u5728\u4e0b\u9762\u53d1\u8868\u8bc4\u8bba\u3002 <\/p>\n<p>\u7f16\u7801\u6109\u5feb\uff01 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728\u4e0d\u5b89\u88c5 Angular CLI \u7684\u60c5\u51b5\u4e0b\u521b\u5efa Angular \u9879\u76ee\u7684\u7279\u5b9a\u7248\u672c\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u60a8\u662f\u5426\u4f7f\u7528 angular \u5e76\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u7684 angular \u7248\u672c\u8bbe\u7f6e\u9879\u76ee\uff1f\u8fd9\u662f\u4e3a\u7279\u5b9a\u7248\u672c\u521b\u5efa angular \u9879\u76ee\u7684\u7b80\u5355\u6307\u5357\uff0c\u65e0\u8bba\u662f\u5426\u4f7f\u7528 angular cli\uff01 \u4e3a\u4ec0\u4e48\u4f7f\u7528\u7279\u5b9a\u7684 angular \u7248\u672c\uff1f \u5728\u5904\u7406\u591a\u4e2a angular \u9879\u76ee\u65f6\uff0c\u6709\u65f6\u60a8\u9700\u8981\u9501\u5b9a\u7279\u5b9a\u7248\u672c\u3002\u4e5f\u8bb8\u60a8\u7684\u9879\u76ee\u4f9d\u8d56\u4e8e\u4ec5\u5728\u7279\u5b9a\u7248\u672c\u4e2d\u53ef\u7528\u7684\u67d0\u4e9b\u529f\u80fd\uff0c\u6216\u8005\u53ef\u80fd\u9700\u8981\u4e0e\u9057\u7559\u4ee3\u7801\u5e93\u517c\u5bb9\u3002 \u4ee5\u4e0b\u662f\u5982\u4f55\u521b\u5efa\u5177\u6709\u7279\u5b9a angular \u7248\u672c\u7684\u9879\u76ee &#8211; \u65e0\u8bba\u60a8\u662f\u5426\u4f7f\u7528 cli\uff01 1. \u521b\u5efa angular \u9879\u76ee\u4e0d\u5b89\u88c5 angular cli \u60a8\u662f\u5426\u77e5\u9053\u65e0\u9700\u5b89\u88c5 cli \u5373\u53ef\u521d\u59cb\u5316\u7279\u5b9a\u7248\u672c\u7684 angular \u9879\u76ee\uff1f\u8ba9\u6211\u4eec\u770b\u770b\u8bed\u6cd5\u548c\u793a\u4f8b\u3002 \u53e5\u6cd5 npm init @angular@&lt;version&gt; &lt;project-name&gt; \u767b\u5f55\u540e\u590d\u5236 \u5c06 \u66ff\u6362\u4e3a\u60a8\u60f3\u8981\u7684 angular \u7248\u672c\uff0c\u5e76\u5c06 \u66ff\u6362\u4e3a\u60a8\u7684\u9879\u76ee\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a sampleapp \u7684 angular 16 \u9879\u76ee\uff0c\u60a8\u53ef\u4ee5\u8fd0\u884c\uff1a \u4f8b\u5b50 npm init @angular@16 sampleapp \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u79cd\u65b9\u6cd5\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u57fa\u672c\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1420","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1420"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1420\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}