{"id":675,"date":"2023-02-23T06:21:31","date_gmt":"2023-02-22T22:21:31","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=675"},"modified":"2023-04-30T15:27:50","modified_gmt":"2023-04-30T07:27:50","slug":"nodejs-package-management-tool-yarn-installation-and-usage","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/23\/nodejs-package-management-tool-yarn-installation-and-usage\/","title":{"rendered":"Node.js\u5305\u7ba1\u7406\u5de5\u5177yarn\u5b89\u88c5\u4f7f\u7528"},"content":{"rendered":"<p>Npm\u662fNode.js\u7684\u5305\u7ba1\u7406\u5668\uff0c\u662f\u5168\u7403\u6700\u5927\u7684\u5f00\u6e90\u5e93\u751f\u6001\u7cfb\u7edf\u3002Yarn\u662fFacebook\u6700\u8fd1\u53d1\u5e03\u7684\u4e00\u6b3e\u4f9d\u8d56\u5305\u5b89\u88c5\u5de5\u5177\u3002Yarn\u662f\u4e00\u4e2a\u65b0\u7684\u5feb\u901f\u5b89\u5168\u53ef\u4fe1\u8d56\u7684\u53ef\u4ee5\u66ff\u4ee3NPM\u7684\u4f9d\u8d56\u7ba1\u7406\u5de5\u5177\u3002<\/p>\n<p>Yarn\u8ddfnpm\u7684\u4f5c\u7528\u5dee\u4e0d\u591a\uff0c\u7f13\u5b58\u4e86\u6bcf\u4e2a\u4e0b\u8f7d\u8fc7\u7684\u5305\uff0c\u6240\u4ee5\u518d\u6b21\u4f7f\u7528\u65f6\u65e0\u9700\u91cd\u590d\u4e0b\u8f7d\u3002 \u540c\u65f6\u5229\u7528\u5e76\u884c\u4e0b\u8f7d\u4ee5\u6700\u5927\u5316\u8d44\u6e90\u5229\u7528\u7387\uff0c\u56e0\u6b64\u901f\u5ea6\u66f4\u5feb\u3002<\/p>\n<p>Yarn\u53f7\u79f0\u662f\u6bd4npm\u5feb\u5341\u500d\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff1a<\/p>\n<p><!-- more --><\/p>\n<pre><code>npm install yarn -g<\/code><\/pre>\n<p>\u5207\u6362\u4e3a\u6dd8\u5b9d\u6e90\u624d\u80fd\u611f\u53d7\u5230\u901f\u5ea6\uff1a<\/p>\n<pre><code>yarn config set registry https:\/\/registry.npm.taobao.org --global\nyarn config set disturl https:\/\/npm.taobao.org\/dist --global<\/code><\/pre>\n<p>\u547d\u4ee4\u884c\uff1a<\/p>\n<p>\u521d\u59cb\u5316\uff1a<code>yarn init<\/code><br \/>\n\u5b89\u88c5\u4e00\u4e2a\u5305\uff1a<code>yarn add package_name<\/code><br \/>\n\u66f4\u65b0\u4e00\u4e2a\u5305\uff1a<code>yarn upgrade package_name<\/code><br \/>\n\u5220\u9664\u4e00\u4e2a\u5305\uff1a<code>yarn remove package_name<\/code><br \/>\n\u5b89\u88c5\u6240\u6709\u5305\uff1a<code>yarn<\/code>\u6216\u8005<code>yarn install<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Npm\u662fNode.js\u7684\u5305\u7ba1\u7406\u5668\uff0c\u662f\u5168\u7403\u6700\u5927\u7684\u5f00\u6e90\u5e93\u751f\u6001\u7cfb\u7edf\u3002Yarn\u662fFacebook\u6700\u8fd1\u53d1\u5e03\u7684\u4e00\u6b3e\u4f9d\u8d56\u5305\u5b89 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[187],"class_list":["post-675","post","type-post","status-publish","format-standard","hentry","category-node","tag-yarn"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=675"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/675\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}