macOS 升级node到指定版本

想安装pnpm跑一个前端项目,直接执行 pnpm i 说不支持当前node版本,看样子不得不升级了,mark一下。

pnpm i 
ERROR: This version of pnpm requires at least Node.js v16.14
The current version of Node.js is v16.13.1
Visit https://r.pnpm.io/comp to see the list of past pnpm versions with respective Node.js version support.

第一步,先查看本机node.js版本:

node -v

第二步,清除node.js的cache:

sudo npm cache clean -f

第三步,安装 n 工具,这是个专门用来管理node.js版本的工具。

sudo npm install -g n

第四步,安装指定版本的node.js

sudo n 16.14.0安装node 16.14.0版本(n后面跟你想要安装的node版本号就可以啦)

sudo n latest安装node最新版本

sudo n stable 安装node稳定版本

sudo n rm xx.xx.xx 删除指定node版本

第五步,再次查看本机的node.js版本:

node -v

第六步,更新npm到最新版,不影响使用可以不更新,非必需

sudo npm install npm@latest -g

pnpm使用:https://pnpm.io/zh/motivation


参考:

anzhihe 安志合个人博客,版权所有 丨 如未注明,均为原创 丨 转载请注明转自:https://chegva.com/5856.html | ☆★★每天进步一点点,加油!★★☆ | 

您可能还感兴趣的文章!

发表评论

电子邮件地址不会被公开。 必填项已用*标注