経緯
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
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