{"id":1935,"date":"2023-11-23T16:48:54","date_gmt":"2023-11-23T08:48:54","guid":{"rendered":"http:\/\/zhang.mba\/?p=1935"},"modified":"2023-11-23T16:56:40","modified_gmt":"2023-11-23T08:56:40","slug":"shi-yong-nvm-guan-li-bu-tong-ban-ben-de-node-yu-np","status":"publish","type":"post","link":"https:\/\/zhang.mba\/index.php\/2023\/11\/23\/16\/48\/54\/1935\/shi-yong-nvm-guan-li-bu-tong-ban-ben-de-node-yu-np\/node-js\/zhangzhiqi\/","title":{"rendered":"\u4f7f\u7528 nvm \u7ba1\u7406\u4e0d\u540c\u7248\u672c\u7684 node \u4e0e npm"},"content":{"rendered":"<p>\u5728\u6211\u4eec\u7684\u65e5\u5e38\u5f00\u53d1\u4e2d\u7ecf\u5e38\u4f1a\u9047\u5230\u8fd9\u79cd\u60c5\u51b5\uff1a\u624b\u4e0a\u6709\u597d\u51e0\u4e2a\u9879\u76ee\uff0c\u6bcf\u4e2a\u9879\u76ee\u7684\u9700\u6c42\u4e0d\u540c\uff0c\u8fdb\u800c\u4e0d\u540c\u9879\u76ee\u5fc5\u987b\u4f9d\u8d56\u4e0d\u540c\u7248\u7684 NodeJS \u8fd0\u884c\u73af\u5883\u3002\u5982\u679c\u6ca1\u6709\u4e00\u4e2a\u5408\u9002\u7684\u5de5\u5177\uff0c\u8fd9\u4e2a\u95ee\u9898\u5c06\u975e\u5e38\u68d8\u624b\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/creationix\/nvm\">nvm<\/a>\u00a0\u5e94\u8fd0\u800c\u751f\uff0cnvm \u662f Mac \u4e0b\u7684 node \u7ba1\u7406\u5de5\u5177\uff0c\u6709\u70b9\u7c7b\u4f3c\u7ba1\u7406 Ruby \u7684 rvm\uff0c\u5982\u679c\u9700\u8981\u7ba1\u7406 Windows \u4e0b\u7684 node\uff0c\u5b98\u65b9\u63a8\u8350\u4f7f\u7528\u00a0<a href=\"https:\/\/github.com\/hakobera\/nvmw\">nvmw<\/a>\u00a0\u6216\u00a0<a href=\"https:\/\/github.com\/coreybutler\/nvm-windows\">nvm-windows<\/a>\u3002\u4e0d\u8fc7\uff0cnvm-windows \u5e76\u4e0d\u662f nvm \u7684\u7b80\u5355\u79fb\u690d\uff0c\u4ed6\u4eec\u4e5f\u6ca1\u6709\u4efb\u4f55\u5173\u7cfb\u3002\u4f46\u4e0b\u9762\u4ecb\u7ecd\u7684\u6240\u6709\u547d\u4ee4\uff0c\u90fd\u53ef\u4ee5\u5728 nvm-windows \u4e2d\u8fd0\u884c\u3002<\/p>\n<hr \/>\n<h2><a id=\"nvm%E4%B8%8E-n%E7%9A%84%E5%8C%BA%E5%88%AB\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>nvm \u4e0e n \u7684\u533a\u522b<\/h2>\n<p>node \u7248\u672c\u7ba1\u7406\u5de5\u5177\u8fd8\u6709\u4e00\u4e2a\u662f TJ\u5927\u795e\u7684\u00a0<a href=\"https:\/\/github.com\/tj\/n\">n<\/a>\u00a0\u547d\u4ee4\uff0cn \u547d\u4ee4\u662f\u4f5c\u4e3a\u4e00\u4e2a node \u7684\u6a21\u5757\u800c\u5b58\u5728\uff0c\u800c nvm \u662f\u4e00\u4e2a\u72ec\u7acb\u4e8e node\/npm \u7684\u5916\u90e8 shell \u811a\u672c\uff0c\u56e0\u6b64 n \u547d\u4ee4\u76f8\u6bd4 nvm \u66f4\u52a0\u5c40\u9650\u3002<\/p>\n<p>\u7531\u4e8e npm \u5b89\u88c5\u7684\u6a21\u5757\u8def\u5f84\u5747\u4e3a\u00a0\/usr\/local\/lib\/node_modules\uff0c\u5f53\u4f7f\u7528 n \u5207\u6362\u4e0d\u540c\u7684 node \u7248\u672c\u65f6\uff0c\u5b9e\u9645\u4e0a\u4f1a\u5171\u7528\u5168\u5c40\u7684 node\/npm \u76ee\u5f55\u3002 \u56e0\u6b64\u4e0d\u80fd\u5f88\u597d\u7684\u6ee1\u8db3\u300e\u6309\u4e0d\u540c node \u7248\u672c\u4f7f\u7528\u4e0d\u540c\u5168\u5c40 node \u6a21\u5757\u300f\u7684\u9700\u6c42\u3002<\/p>\n<hr \/>\n<h2><a id=\"%E5%8D%B8%E8%BD%BD%E5%85%A8%E5%B1%80%E5%AE%89%E8%A3%85%E7%9A%84nodenpm\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5378\u8f7d\u5168\u5c40\u5b89\u88c5\u7684 node\/npm<\/h2>\n<p>\u5728\u5b98\u7f51\u4e0b\u8f7d\u7684 node \u5b89\u88c5\u5305\uff0c\u8fd0\u884c\u540e\u4f1a\u81ea\u52a8\u5b89\u88c5\u5728\u5168\u5c40\u76ee\u5f55\uff0c\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b<strong>\u6743\u9650\u95ee\u9898<\/strong>\uff0c\u6240\u4ee5\u63a8\u8350\u6309\u7167\u4ee5\u4e0b\u65b9\u6cd5\u5378\u8f7d\u5168\u5c40\u5b89\u88c5\u7684 node\/npm\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6253\u5f00\u4f60 Finder\uff0c\u6309\u00a0shift+command+G\uff0c\u6253\u5f00\u524d\u5f80\u6587\u4ef6\u5939\u7684\u7a97\u53e3\uff0c\u5206\u522b\u8f93\u5165\u4e0b\u5217\u76ee\u5f55\u8fdb\u53bb\u4e4b\u540e\u5220\u9664\u00a0node\u00a0\u548c\u00a0node_modules\u00a0\u76f8\u5173\u7684\u6587\u4ef6\u548c\u6587\u4ef6\u5939:<\/p>\n<ul>\n<li>\u6253\u5f00\u00a0\/usr\/local\/lib\uff0c\u5220\u9664\u00a0node\u00a0\u548c\u00a0node_modules\u00a0\u76f8\u5173\u7684\u6587\u4ef6\u548c\u6587\u4ef6\u5939<\/li>\n<li>\u6253\u5f00\u00a0\/usr\/local\/include\uff0c\u5220\u9664\u00a0node\u00a0\u548c\u00a0node_modules\u00a0\u76f8\u5173\u7684\u6587\u4ef6\u548c\u6587\u4ef6\u5939<\/li>\n<li>\u5982\u679c\u4f60\u662f\u4f7f\u7528\u7684\u00a0brew install node\u00a0\u5b89\u88c5\u7684 NodeJS\uff0c\u90a3\u4e48\u4f60\u8fd8\u9700\u8981\u5728\u7ec8\u7aef\u4e2d\u6267\u884c\u00a0brew uninstall node\u00a0\u547d\u4ee4\u6765\u5378\u8f7d<\/li>\n<li>\u68c0\u67e5\u4f60\u7684\u4e2a\u4eba\u4e3b\u6587\u4ef6\u5939\u4e0b\u9762\u7684\u6240\u6709\u7684\u00a0local\u3001lib\u00a0\u4ee5\u53ca\u00a0include\u00a0\u6587\u4ef6\u5939\uff0c\u5e76\u4e14\u5220\u9664\u6240\u6709\u4e0e\u00a0node\u00a0\u548c\u00a0node_modules\u00a0\u76f8\u5173\u7684\u6587\u4ef6\u4ee5\u53ca\u6587\u4ef6\u5939<\/li>\n<li>\u6253\u5f00\u00a0\/usr\/local\/bin\u00a0\u5e76\u5220\u9664\u00a0node\u00a0\u53ef\u6267\u884c\u6587\u4ef6<\/li>\n<\/ul>\n<p>\u4f60\u53ef\u80fd\u8fd8\u9700\u8981\u5728\u4f60\u7684\u7ec8\u7aef\u4e2d\u8f93\u5165\u4e00\u4e9b\u989d\u5916\u7684\u6307\u4ee4\uff1a<\/p>\n<p>sudo rm \/usr\/local\/bin\/npm<br \/>\nsudo rm \/usr\/local\/share\/man\/man1\/node.1<br \/>\nsudo rm \/usr\/local\/lib\/dtrace\/node.d<br \/>\nsudo rm -rf ~\/.npm<br \/>\nsudo rm -rf ~\/.node-gyp<br \/>\nsudo rm \/opt\/local\/bin\/node<br \/>\nsudo rm \/opt\/local\/include\/node<br \/>\nsudo rm -rf \/opt\/local\/lib\/node_modules<\/p>\n<hr \/>\n<h2><a id=\"windows%E5%AE%89%E8%A3%85\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>Windows \u5b89\u88c5<\/h2>\n<p>\u9996\u5148\u6700\u91cd\u8981\u7684\u662f\uff1a\u4e00\u5b9a\u8981\u5378\u8f7d\u5df2\u5b89\u88c5\u7684 NodeJS\uff0c\u5426\u5219\u4f1a\u53d1\u751f\u51b2\u7a81\u3002\u7136\u540e\u4e0b\u8f7d\u00a0<a href=\"https:\/\/github.com\/coreybutler\/nvm-windows\/releases\">nvm-windows<\/a>\u00a0\u6700\u65b0\u5b89\u88c5\u5305\uff0c\u76f4\u63a5\u5b89\u88c5\u5373\u53ef\u3002<\/p>\n<hr \/>\n<h2><a id=\"os-xlinux%E5%AE%89%E8%A3%85\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>OS X\/Linux \u5b89\u88c5<\/h2>\n<p>\u4e0e Windows \u4e0d\u540c\uff0c\u6211\u4eec\u5e76\u4e0d\u4e00\u5b9a\u8981\u5148\u5378\u8f7d\u539f\u6709\u7684 NodeJS\u3002\u5f53\u7136\u6211\u4eec\u63a8\u8350\u8fd8\u662f\u5148\u5378\u8f7d\u6389\u6bd4\u8f83\u597d\u3002\u53e6\u5916\uff0c\u4f60\u8fd8\u9700\u8981 C++ \u7f16\u8bd1\u5668\uff0cLinux \u53d1\u884c\u7248\u4e00\u822c\u4e0d\u7528\u62c5\u5fc3\uff0c\u50cf Ubuntu \u90fd\u53ef\u4ee5\u76f4\u63a5\u7528\u00a0build-essential\u00a0\u5957\u4ef6\uff0cOS X \u7684\u8bdd\uff0c\u53ef\u4ee5\u7528\u00a0X-Code\u00a0\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002\u8fd0\u884c\u8fd9\u4e2a\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<p>xcode-select &#8211;install<\/p>\n<p>\u5728 Linux \u4e2d\uff1a\uff08\u5982\u679c\u662f Debian \u53d1\u884c\u7248\uff09<\/p>\n<p>sudo apt-get install build-essential<\/p>\n<p>\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<\/p>\n<p>curl -o- <a href=\"https:\/\/raw.githubusercontent.com\/creationix\/nvm\/v0.33.0\/install.sh\">https:\/\/raw.githubusercontent.com\/creationix\/nvm\/v0.33.0\/install.sh<\/a> | bash<\/p>\n<p>\u6216\u8005<\/p>\n<p>wget -qO- <a href=\"https:\/\/raw.githubusercontent.com\/creationix\/nvm\/v0.33.0\/install.sh\">https:\/\/raw.githubusercontent.com\/creationix\/nvm\/v0.33.0\/install.sh<\/a> | bash<\/p>\n<p>\u4ece\u8fdc\u7a0b\u4e0b\u8f7d\u00a0install.sh\u00a0\u811a\u672c\u5e76\u6267\u884c\u3002\u6ce8\u610f\u8fd9\u4e2a\u7248\u672c\u5e74\u6570\u5b57\u00a0v0.33.0\u00a0\u4f1a\u968f\u7740\u9879\u76ee\u5f00\u53d1\u800c\u53d8\u5316\u3002\u968f\u65f6\u901a\u8fc7<a href=\"https:\/\/github.com\/creationix\/nvm#install-script\">\u5b98\u65b9\u6700\u65b0\u5b89\u88c5\u547d\u4ee4<\/a>\u6765\u68c0\u67e5\u6700\u65b0\u5b89\u88c5\u7248\u672c\u662f\u6709\u597d\u5904\u7684\u3002<\/p>\n<hr \/>\n<h2><a id=\"%E5%AE%89%E8%A3%85%E5%A4%9A%E7%89%88%E6%9C%ACnodenpm\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5b89\u88c5\u591a\u7248\u672c node\/npm<\/h2>\n<p>\u4f8b\u5982\uff0c\u6211\u4eec\u8981\u5b89\u88c54.2.2\u7248\u672c\uff0c\u53ef\u4ee5\u7528\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>nvm install 4.2.2<\/p>\n<p>nvm \u9075\u5b88<a href=\"http:\/\/semver.org\/lang\/zh-CN\/\">\u8bed\u4e49\u5316\u7248\u672c<\/a>\u547d\u540d\u89c4\u5219\u3002\u4f8b\u5982\uff0c\u4f60\u60f3\u5b89\u88c5\u6700\u65b0\u7684\u00a04.2\u00a0\u7cfb\u5217\u7684\u6700\u65b0\u7684\u4e00\u4e2a\u7248\u672c\u7684\u8bdd\uff0c\u53ef\u4ee5\u8fd0\u884c\uff1a<\/p>\n<p>nvm install 4.2<\/p>\n<p>nvm \u4f1a\u5bfb\u627e\u00a04.2.x\u00a0\u4e2d\u6700\u9ad8\u7684\u7248\u672c\u6765\u5b89\u88c5\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u5217\u51fa\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u6240\u6709\u7684\u53ef\u7528\u7248\u672c\uff1a<\/p>\n<p>nvm ls-remote<\/p>\n<p>Windows \u7684\u8bdd\uff0c\u5c31\u662f\uff1a<\/p>\n<p>nvm ls available<\/p>\n<hr \/>\n<h2><a id=\"%E5%9C%A8%E4%B8%8D%E5%90%8C%E7%89%88%E6%9C%AC%E9%97%B4%E5%88%87%E6%8D%A2\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5728\u4e0d\u540c\u7248\u672c\u95f4\u5207\u6362<\/h2>\n<p>\u6bcf\u5f53\u6211\u4eec\u5b89\u88c5\u4e86\u4e00\u4e2a\u65b0\u7248\u672c Node \u540e\uff0c\u5168\u5c40\u73af\u5883\u4f1a\u81ea\u52a8\u628a\u8fd9\u4e2a\u65b0\u7248\u672c\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u3002<\/p>\n<p>nvm \u63d0\u4f9b\u4e86\u00a0nvm use\u00a0\u547d\u4ee4\u3002\u8fd9\u4e2a\u547d\u4ee4\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u00a0install\u00a0\u547d\u4ee4\u7c7b\u4f3c\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5207\u6362\u5230\u00a04.2.2\uff1a<\/p>\n<p>nvm use 4.2.2<\/p>\n<p>\u5207\u6362\u5230\u6700\u65b0\u7684\u00a04.2.x\uff1a<\/p>\n<p>nvm use 4.2<\/p>\n<p>\u5207\u6362\u5230 iojs\uff1a<\/p>\n<p>nvm use iojs-v3.2.0<\/p>\n<p>\u5207\u6362\u5230\u6700\u65b0\u7248\uff1a<\/p>\n<p>nvm use node<\/p>\n<p>\u6bcf\u6b21\u6267\u884c\u5207\u6362\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u90fd\u4f1a\u628a node \u7684\u53ef\u6267\u884c\u6587\u4ef6\u94fe\u63a5\u653e\u5230\u7279\u5b9a\u7248\u672c\u7684\u6587\u4ef6\u4e0a\u3002<\/p>\n<p>\u6211\u4eec\u8fd8\u53ef\u4ee5\u7528 nvm \u7ed9\u4e0d\u540c\u7684\u7248\u672c\u53f7\u8bbe\u7f6e\u522b\u540d\uff1a<\/p>\n<p>nvm alias awesome-version 4.2.2<\/p>\n<p>\u6211\u4eec\u7ed9\u00a04.2.2\u00a0\u8fd9\u4e2a\u7248\u672c\u53f7\u8d77\u4e86\u4e00\u4e2a\u540d\u5b57\u53eb\u505a\u00a0awesome-version\uff0c\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u8fd0\u884c\uff1a<\/p>\n<p>nvm use awesome-version<\/p>\n<p>\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4\u53ef\u4ee5\u53d6\u6d88\u522b\u540d\uff1a<\/p>\n<p>nvm unalias awesome-version<\/p>\n<p>\u53e6\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u8bbe\u7f6e\u00a0default\u00a0\u8fd9\u4e2a\u7279\u6b8a\u522b\u540d\uff1a<\/p>\n<p>nvm alias default node<\/p>\n<hr \/>\n<h2><a id=\"%E5%88%97%E5%87%BA%E5%B7%B2%E5%AE%89%E8%A3%85%E5%AE%9E%E4%BE%8B\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5217\u51fa\u5df2\u5b89\u88c5\u5b9e\u4f8b<\/h2>\n<p>nvm ls<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.runoob.com\/wp-content\/uploads\/2018\/04\/nvm-ls.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/www.runoob.com\/wp-content\/uploads\/2018\/04\/nvm-ls.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u4e0a\u9762\u7eff\u8272\u7bad\u5934\u662f\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u7248\u672c\uff0c\u4e0b\u9762\u5217\u51fa\u7684\u8fd8\u6709\u8bbe\u7f6e\u8fc7\u7684\u522b\u540d\u3002<\/p>\n<hr \/>\n<h2><a id=\"%E5%9C%A8%E9%A1%B9%E7%9B%AE%E4%B8%AD%E4%BD%BF%E7%94%A8%E4%B8%8D%E5%90%8C%E7%89%88%E6%9C%AC%E7%9A%84node\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5728\u9879\u76ee\u4e2d\u4f7f\u7528\u4e0d\u540c\u7248\u672c\u7684 Node<\/h2>\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u9879\u76ee\u76ee\u5f55\u4e2d\u7684\u00a0.nvmrc\u00a0\u6587\u4ef6\u6765\u6307\u5b9a\u8981\u4f7f\u7528\u7684 Node \u7248\u672c\u3002\u4e4b\u540e\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u6267\u884c\u00a0nvm use\u00a0\u5373\u53ef\u3002.nvmrc\u00a0\u6587\u4ef6\u5185\u5bb9\u53ea\u9700\u8981\u9075\u5b88\u4e0a\u6587\u63d0\u5230\u7684\u8bed\u4e49\u5316\u7248\u672c\u89c4\u5219\u5373\u53ef\u3002\u53e6\u5916\u8fd8\u6709\u4e2a\u5de5\u5177\u53eb\u505a\u00a0<a href=\"https:\/\/github.com\/wbyoung\/avn\">avn<\/a>\uff0c\u53ef\u4ee5\u81ea\u52a8\u5316\u8fd9\u4e2a\u8fc7\u7a0b\u3002<\/p>\n<hr \/>\n<h2><a id=\"%E5%9C%A8%E5%A4%9A%E7%8E%AF%E5%A2%83%E4%B8%AD%EF%BC%8Cnpm%E8%AF%A5%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E5%91%A2%EF%BC%9F\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5728\u591a\u73af\u5883\u4e2d\uff0cnpm\u8be5\u5982\u4f55\u4f7f\u7528\u5462\uff1f<\/h2>\n<p>\u6bcf\u4e2a\u7248\u672c\u7684 Node \u90fd\u4f1a\u81ea\u5e26\u4e00\u4e2a\u4e0d\u540c\u7248\u672c\u7684 npm\uff0c\u53ef\u4ee5\u7528\u00a0npm -v\u00a0\u6765\u67e5\u770b npm \u7684\u7248\u672c\u3002\u5168\u5c40\u5b89\u88c5\u7684 npm \u5305\u5e76\u4e0d\u4f1a\u5728\u4e0d\u540c\u7684 Node \u73af\u5883\u4e2d\u5171\u4eab\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u5f15\u8d77\u517c\u5bb9\u95ee\u9898\u3002\u5b83\u4eec\u88ab\u653e\u5728\u4e86\u4e0d\u540c\u7248\u672c\u7684\u76ee\u5f55\u4e0b\uff0c\u4f8b\u5982\u00a0~\/.nvm\/versions\/node\/<version>\/lib\/node_modules<\/version>\u00a0\u8fd9\u6837\u7684\u76ee\u5f55\u3002\u8fd9\u521a\u597d\u4e5f\u7701\u53bb\u6211\u4eec\u5728 Linux \u4e2d\u4f7f\u7528\u00a0sudo\u00a0\u7684\u529f\u592b\u4e86\u3002\u56e0\u4e3a\u8fd9\u662f\u7528\u6237\u7684\u4e3b\u6587\u4ef6\u5939\uff0c\u5e76\u4e0d\u4f1a\u5f15\u8d77\u6743\u9650\u95ee\u9898\u3002<\/p>\n<p>\u4f46\u95ee\u9898\u6765\u4e86\uff0c\u6211\u4eec\u5b89\u88c5\u8fc7\u7684 npm \u5305\uff0c\u90fd\u8981\u91cd\u65b0\u518d\u88c5\u4e00\u6b21\uff1f\u5e78\u8fd0\u7684\u662f\uff0c\u6211\u4eec\u6709\u4e2a\u529e\u6cd5\u6765\u89e3\u51b3\u6211\u4eec\u7684\u95ee\u9898\uff0c\u8fd0\u884c\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4\uff0c\u53ef\u4ee5\u4ece\u7279\u5b9a\u7248\u672c\u5bfc\u5165\u5230\u6211\u4eec\u5c06\u8981\u5b89\u88c5\u7684\u65b0\u7248\u672c Node\uff1a<\/p>\n<p>nvm install v5.0.0 &#8211;reinstall-packages-from=4.2<\/p>\n<hr \/>\n<h2><a id=\"%E5%85%B6%E4%BB%96%E5%91%BD%E4%BB%A4\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u5176\u4ed6\u547d\u4ee4<\/h2>\n<p>\u76f4\u63a5\u8fd0\u884c\u7279\u5b9a\u7248\u672c\u7684 Node<\/p>\n<p>nvm run 4.2.2 &#8211;version<\/p>\n<p>\u5728\u5f53\u524d\u7ec8\u7aef\u7684\u5b50\u8fdb\u7a0b\u4e2d\u8fd0\u884c\u7279\u5b9a\u7248\u672c\u7684 Node<\/p>\n<p>nvm exec 4.2.2 node &#8211;version<\/p>\n<p>\u786e\u8ba4\u67d0\u4e2a\u7248\u672cNode\u7684\u8def\u5f84<\/p>\n<p>nvm which 4.2.2<\/p>\n<p>\u5b89\u88c5 Node \u7684\u5176\u4ed6\u5b9e\u73b0\uff0c\u4f8b\u5982 iojs\uff08\u4e00\u4e2a\u57fa\u4e8e ES6 \u7684 Node \u5b9e\u73b0\uff0c\u73b0\u5728\u5df2\u7ecf\u548c Node \u5408\u5e76\uff09<\/p>\n<p>nvm install iojs-v3.2.0<\/p>\n<p>\u5feb\u6377\u547d\u4ee4\uff1a<\/p>\n<ul>\n<li>nvm install node\u00a0\u5b89\u88c5\u6700\u65b0\u7248 Node<\/li>\n<li>nvm install iojs\u00a0\u5b89\u88c5\u6700\u65b0\u7248 iojs<\/li>\n<li>nvm install unstable\u00a0\u5b89\u88c5\u6700\u65b0\u4e0d\u7a33\u5b9a\u7248\u672c\u7684 Node<\/li>\n<\/ul>\n<blockquote>\n<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"http:\/\/bubkoo.com\/2017\/01\/08\/quick-tip-multiple-versions-node-nvm\/\">http:\/\/bubkoo.com\/2017\/01\/08\/quick-tip-multiple-versions-node-nvm\/<\/a><\/p>\n<\/blockquote>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5728\u6211\u4eec\u7684\u65e5\u5e38\u5f00\u53d1\u4e2d\u7ecf\u5e38\u4f1a\u9047\u5230\u8fd9\u79cd\u60c5\u51b5\uff1a\u624b\u4e0a\u6709\u597d\u51e0\u4e2a\u9879\u76ee\uff0c\u6bcf\u4e2a\u9879\u76ee\u7684\u9700\u6c42\u4e0d\u540c\uff0c\u8fdb\u800c\u4e0d\u540c\u9879\u76ee\u5fc5\u987b\u4f9d\u8d56\u4e0d\u540c\u7248\u7684 NodeJS \u8fd0\u884c\u73af\u5883\u3002\u5982\u679c\u6ca1\u6709\u4e00\u4e2a\u5408\u9002\u7684\u5de5\u5177\uff0c\u8fd9\u4e2a\u95ee\u9898\u5c06\u975e\u5e38\u68d8\u624b\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[74],"tags":[75],"_links":{"self":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts\/1935"}],"collection":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/comments?post=1935"}],"version-history":[{"count":0,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts\/1935\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/media?parent=1935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/categories?post=1935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/tags?post=1935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}