{"id":1955,"date":"2026-06-19T12:53:34","date_gmt":"2026-06-19T04:53:34","guid":{"rendered":"https:\/\/blog.ttwow.top\/?p=1955"},"modified":"2026-06-19T21:55:10","modified_gmt":"2026-06-19T13:55:10","slug":"npm%e7%9a%84%e4%b8%80%e4%ba%9b%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/blog.ttwow.top\/?p=1955","title":{"rendered":"npm\u7684\u4e00\u4e9b\u547d\u4ee4"},"content":{"rendered":"<pre><code class=\"language-md\"># Node.js \u4f9d\u8d56\u7ba1\u7406\u5de5\u5177\u547d\u4ee4\u8bf4\u660e\n\n## 1. \u5b89\u88c5 pnpm\uff08\u63a8\u8350\uff09\n\n```bash\nnpm install -g pnpm<\/code><\/pre>\n<h3>\u4f5c\u7528<\/h3>\n<ul>\n<li>\u5b89\u88c5 pnpm \u5168\u5c40\u5de5\u5177<\/li>\n<li>pnpm \u662f\u66f4\u9ad8\u6548\u7684 Node.js \u5305\u7ba1\u7406\u5668<\/li>\n<li>\u7279\u70b9\uff1a\u5b89\u88c5\u901f\u5ea6\u5feb\u3001\u8282\u7701\u78c1\u76d8\u7a7a\u95f4\uff08\u4f7f\u7528\u786c\u94fe\u63a5\u673a\u5236\uff09<\/li>\n<\/ul>\n<hr \/>\n<h2>2. \u5b89\u88c5 yarn<\/h2>\n<pre><code class=\"language-bash\">npm install -g yarn<\/code><\/pre>\n<h3>\u4f5c\u7528<\/h3>\n<ul>\n<li>\u5b89\u88c5 Yarn \u5305\u7ba1\u7406\u5668<\/li>\n<li>\u5e38\u7528\u4e8e React \/ Vue \u9879\u76ee<\/li>\n<li>\u66ff\u4ee3 npm \u7684\u53e6\u4e00\u79cd\u4f9d\u8d56\u7ba1\u7406\u65b9\u6848<\/li>\n<\/ul>\n<hr \/>\n<h2>3. \u5b89\u88c5 rimraf<\/h2>\n<pre><code class=\"language-bash\">npm install rimraf -g<\/code><\/pre>\n<h3>\u4f5c\u7528<\/h3>\n<ul>\n<li>\u5b89\u88c5 rimraf\uff08\u8de8\u5e73\u53f0\u5220\u9664\u5de5\u5177\uff09<\/li>\n<li>\u76f8\u5f53\u4e8e Linux \u7684 <code>rm -rf<\/code><\/li>\n<li>Windows \/ Linux \/ Mac \u90fd\u53ef\u7528<\/li>\n<\/ul>\n<hr \/>\n<h2>4. \u5220\u9664 node_modules<\/h2>\n<pre><code class=\"language-bash\">rimraf node_modules<\/code><\/pre>\n<h3>\u4f5c\u7528<\/h3>\n<ul>\n<li>\u5220\u9664\u5f53\u524d\u9879\u76ee\u7684 node_modules \u4f9d\u8d56\u76ee\u5f55<\/li>\n<li>\n<p>\u5e38\u7528\u4e8e\uff1a<\/p>\n<ul>\n<li>\u4f9d\u8d56\u635f\u574f<\/li>\n<li>\u5b89\u88c5\u5931\u8d25<\/li>\n<li>\u91cd\u65b0\u521d\u59cb\u5316\u9879\u76ee<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>5. \u5e38\u89c1\u7ec4\u5408\u64cd\u4f5c\uff08\u4fee\u590d\u4f9d\u8d56\uff09<\/h2>\n<pre><code class=\"language-bash\"># \u5220\u9664\u4f9d\u8d56\u76ee\u5f55\nrimraf node_modules\n\n# \uff08\u53ef\u9009\uff09\u5220\u9664\u9501\u6587\u4ef6\nrimraf package-lock.json\nrimraf pnpm-lock.yaml\nrimraf yarn.lock\n\n# \u91cd\u65b0\u5b89\u88c5\u4f9d\u8d56\uff08\u6309\u9879\u76ee\u7c7b\u578b\u9009\u62e9\uff09\n\nnpm install\n# \u6216\npnpm install\n# \u6216\nyarn install<\/code><\/pre>\n<hr \/>\n<h2>6. \u7248\u672c\u68c0\u67e5<\/h2>\n<pre><code class=\"language-bash\">node -v\nnpm -v\npnpm -v\nyarn -v\nrimraf --version<\/code><\/pre>\n<hr \/>\n<h2>7. Debian \/ Ubuntu \u4e00\u952e\u73af\u5883\u521d\u59cb\u5316<\/h2>\n<pre><code class=\"language-bash\"># \u66f4\u65b0\u7cfb\u7edf\napt update &amp;&amp; apt upgrade -y\n\n# \u5b89\u88c5\u57fa\u7840\u5de5\u5177\napt install curl -y\n\n# \u5b89\u88c5 Node.js LTS\uff08\u63a8\u8350 22\uff09\ncurl -fsSL https:\/\/deb.nodesource.com\/setup_22.x | bash -\napt install nodejs -y\n\n# \u5b89\u88c5\u5305\u7ba1\u7406\u5de5\u5177\nnpm install -g pnpm\nnpm install -g yarn\nnpm install -g rimraf<\/code><\/pre>\n<hr \/>\n<h2>\u63a8\u8350\u4f7f\u7528\u65b9\u5f0f<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5de5\u5177<\/th>\n<th>\u63a8\u8350\u7a0b\u5ea6<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>pnpm<\/td>\n<td>\u2b50\u2b50\u2b50\u2b50\u2b50<\/td>\n<td>\u6700\u5feb\u3001\u6700\u7701\u7a7a\u95f4\uff08\u63a8\u8350\u9ed8\u8ba4\u4f7f\u7528\uff09<\/td>\n<\/tr>\n<tr>\n<td>yarn<\/td>\n<td>\u2b50\u2b50\u2b50<\/td>\n<td>\u8001\u724c\u65b9\u6848\uff0c\u90e8\u5206\u9879\u76ee\u4f9d\u8d56<\/td>\n<\/tr>\n<tr>\n<td>npm<\/td>\n<td>\u2b50\u2b50\u2b50\u2b50<\/td>\n<td>\u5b98\u65b9\u9ed8\u8ba4<\/td>\n<\/tr>\n<tr>\n<td>rimraf<\/td>\n<td>\u2b50\u2b50\u2b50\u2b50\u2b50<\/td>\n<td>\u5fc5\u5907\u6e05\u7406\u5de5\u5177<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre><code>\n\u5982\u679c\u4f60\u8981\uff0c\u6211\u53ef\u4ee5\u518d:contentReference[oaicite:0]{index=0}\u3002<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p># Node.js \u4f9d\u8d56\u7ba1\u7406\u5de5\u5177\u547d\u4ee4\u8bf4\u660e ## 1. \u5b89\u88c5 pnpm\uff08\u63a8\u8350\uff09 &#8220;`bash npm inst [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[129],"tags":[],"class_list":["post-1955","post","type-post","status-publish","format-standard","hentry","category-frontend-web"],"_links":{"self":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1955"}],"version-history":[{"count":1,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1955\/revisions"}],"predecessor-version":[{"id":1956,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1955\/revisions\/1956"}],"wp:attachment":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}