【Windows】升级yarn到最新版本的步骤

经过 or 历程

我想要记录并能够回顾使用npm等频繁更新的中间件执行过程的备忘录。

版本升级步骤

更新npm版本

由于有一些情况需要升级node.js版本,因此建议定期更新到最新版本。对于Windows用户来说,我个人建议使用下面的网站下载MSI安装程序来安装。

 

这次尝试更新npm@10时,由于不支持nodejs16,必须要升级到18以上版本。

C:\Users\masas>npm install -g npm@10.2.1 
npm WARN cli npm v10.2.1 does not support Node.js v16.16.0. This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: npm@10.2.1
npm ERR! notsup Not compatible with your version of node/npm: npm@10.2.1
npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"}
npm ERR! notsup Actual:   {"npm":"10.2.1","node":"v16.16.0"}

npm ERR! A complete log of this run can be found in: C:\Users\masas\AppData\Local\npm-cache\_logs\2023-10-28T12_44_58_217Z-debug-0.log
image.png

如果使用MSI安装程序进行安装,它将安装到C驱动的C:\ Program Files \ nodejs文件夹中,因此需要使用管理员权限来启动命令提示符和PowerShell来运行应用程序。

确认版本的方法

PS C:\Users\masas> npm -v
10.2.1

更新 yarn 的版本

使用yarn set命令来更新至最新版本。

C:\Users\masas>yarn set version latest #最新はVer4
➤ YN0000: Downloading https://repo.yarnpkg.com/4.0.0/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.0.0.cjs
➤ YN0000: Done in 0s 453ms

C:\Users\masas>yarn --version
4.0.0

 

广告
将在 10 秒后关闭
bannerAds