wingetでNVM(node.jsのバージョン管理ツール)をインストールして、適当なバージョンのnode.jsもインストールします。
nvmのインストール
まずは探す。
> winget search nvm 名前 ID バージョン 一致 ソース ---------------------------------------------------------------------------------------------------------------- NVM for Windows CoreyButler.NVMforWindows 1.2.2 Command: nvm winget Fast Node Manager Schniz.fnm 1.38.1 Tag: nvm winget Volta Volta.Volta 2.0.2 Tag: nvm winget OpenKey Tuyenvm.OpenKey 2.0.5 winget CrystalDiskInfo CrystalDewWorld.CrystalDiskInfo 9.6.3 Tag: nvme winget CrystalDiskInfo Aoi Edition CrystalDewWorld.CrystalDiskInfo.AoiEdition 9.6.3 Tag: nvme winget CrystalDiskInfo Kurei Kei Edition CrystalDewWorld.CrystalDiskInfo.KureiKeiEdition 9.6.3 Tag: nvme winget CrystalDiskInfo Shizuku Edition CrystalDewWorld.CrystalDiskInfo.ShizukuEdition 9.6.3 Tag: nvme winget
一番上のやつが入れたいそれらしい。 IDを指定してインストールする。
winget install CoreyButler.NVMforWindows
今開いているターミナルだとパスが通っていないので、いったんターミナルを再起動する(vscode内ターミナルならvscode自体を再起動する)。
インストールできたか確認:
> nvm -v 1.2.2
nvmでnode.jsのインストール
インストール可能なバージョンを確認する。
> nvm list available | CURRENT | LTS | OLD STABLE | OLD UNSTABLE | |--------------|--------------|--------------|--------------| | 24.2.0 | 22.16.0 | 0.12.18 | 0.11.16 | | 24.1.0 | 22.15.1 | 0.12.17 | 0.11.15 | | 24.0.2 | 22.15.0 | 0.12.16 | 0.11.14 | | 24.0.1 | 22.14.0 | 0.12.15 | 0.11.13 | | 24.0.0 | 22.13.1 | 0.12.14 | 0.11.12 | | 23.11.1 | 22.13.0 | 0.12.13 | 0.11.11 | | 23.11.0 | 22.12.0 | 0.12.12 | 0.11.10 | | 23.10.0 | 22.11.0 | 0.12.11 | 0.11.9 | | 23.9.0 | 20.19.2 | 0.12.10 | 0.11.8 | | 23.8.0 | 20.19.1 | 0.12.9 | 0.11.7 | | 23.7.0 | 20.19.0 | 0.12.8 | 0.11.6 | | 23.6.1 | 20.18.3 | 0.12.7 | 0.11.5 | | 23.6.0 | 20.18.2 | 0.12.6 | 0.11.4 | | 23.5.0 | 20.18.1 | 0.12.5 | 0.11.3 | | 23.4.0 | 20.18.0 | 0.12.4 | 0.11.2 | | 23.3.0 | 20.17.0 | 0.12.3 | 0.11.1 | | 23.2.0 | 20.16.0 | 0.12.2 | 0.11.0 | | 23.1.0 | 20.15.1 | 0.12.1 | 0.9.12 | | 23.0.0 | 20.15.0 | 0.12.0 | 0.9.11 | | 22.10.0 | 20.14.0 | 0.10.48 | 0.9.10 | This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases
最新のLTS版をインストールする。
> nvm install lts Downloading node.js version 22.16.0 (64-bit)... Extracting node and npm... Complete Installation complete. If you want to use this version, type: nvm use 22.16.0
最新版が欲しければlatestを指定する。22.16.0のように直接バージョンを指定することも可能。
インストール済みのバージョンを確認:
> nvm list
22.16.0
インストールしただけではnodeは使えない。
> node -v
node : 用語 'node' は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。名前が正しく記述され
ていることを確認し、パスが含まれている場合はそのパスが正しいことを確認してから、再試行してください。
発生場所 行:1 文字:1
+ node -v
+ ~~~~
+ CategoryInfo : ObjectNotFound: (node:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
さっきインストールしたLTS版を使うようにする(バージョン切り替え)。
> nvm use lts Now using node v22.16.0 (64-bit)
もちろん、直接バージョン指定も可能:
> nvm use 22.16.0 Now using node v22.16.0 (64-bit)
latestや、newest(インストール済みの中で一番バージョンが新しいもの)も指定可能:
> nvm use latest 24.2.0 activation error: Version not installed. Run "nvm ls" to see available versions. > nvm use newest Now using node v22.16.0 (64-bit)
latestはインストールしてなかったので、その旨のエラーが出る。
そんなこんなでnode.jsとnpmが使えるようになった:
> node -v v22.16.0 > npm -v 10.9.2
メモ
windows用のnvmは、linuxとかmac用のやつとは異なるらしい。 なんか使えるコマンドとかも違うし。ググるときは「windows」って入れた方がよさそう。
おまけ:nmvのヘルプ
ヘルプは単に nvm と打てば出てくる。アメリカ語だが。
> nvm
Running version 1.2.2.
Usage:
nvm arch : Show if node is running in 32 or 64 bit mode.
nvm current : Display active version.
nvm debug : Check the NVM4W process for known problems (troubleshooter).
nvm install <version> [arch] : The version can be a specific version, "latest" for the latest current version, or "lts" for the
most recent LTS version. Optionally specify whether to install the 32 or 64 bit version (defaults
to system arch). Set [arch] to "all" to install 32 AND 64 bit versions.
Add --insecure to the end of this command to bypass SSL validation of the remote download server.
nvm list [available] : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.
nvm on : Enable node.js version management.
nvm off : Disable node.js version management.
nvm proxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.
Set [url] to "none" to remove the proxy.
nvm node_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.
nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.
nvm uninstall <version> : The version must be a specific version.
nvm upgrade : Update nvm to the latest version. Manual rollback available for 7 days after upgrade.
nvm use [version] [arch] : Switch to use the specified version. Optionally use "latest", "lts", or "newest".
"newest" is the latest installed version. Optionally specify 32/64bit architecture.
nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.
nvm reinstall <version> : A shortcut method to clean and reinstall a specific version.
nvm root [path] : Set the directory where nvm should store different versions of node.js.
If <path> is not set, the current root will be displayed.
nvm subscribe [--]<topic> : Subscribe to desktop notifications.
Valid topics: lts, current, nvm4w, author
nvm unsubscribe [--]<topic> : Unsubscribe from desktop notifications.
Valid topics: lts, current, nvm4w, author
nvm [--]version : Displays the current running version of nvm for Windows. Aliased as v.
ChatGPT4.1の翻訳:
> nvm
バージョン 1.2.2 を実行中。
使用法:
nvm arch : nodeが32ビットモードか64ビットモードかを表示します。
nvm current : アクティブなバージョンを表示します。
nvm debug : NVM4Wプロセスの既知の問題を確認します(トラブルシューティング)。
nvm install <version> [arch] : バージョンは特定のバージョンを指定できます。"latest"は最新の現行バージョン、"lts"は
最新のLTSバージョンです。オプションで32ビットまたは64ビットバージョンを指定できます(デフォルトは
システムのアーキテクチャ)。[arch]に"all"を指定すると32ビットと64ビット両方をインストールします。
このコマンドの末尾に--insecureを付けると、リモートダウンロードサーバーのSSL検証をバイパスします。
nvm list [available] : node.jsのインストール済みバージョンを一覧表示します。末尾に"available"を入力するとインストール可能なバージョンを表示します。lsも同じ意味です。
nvm on : node.jsバージョン管理を有効にします。
nvm off : node.jsバージョン管理を無効にします。
nvm proxy [url] : ダウンロード用のプロキシを設定します。[url]を空欄にすると現在のプロキシを表示します。
[url]に"none"を指定するとプロキシを解除します。
nvm node_mirror [url] : nodeのミラーを設定します。デフォルトはhttps://nodejs.org/dist/です。[url]を空欄にするとデフォルトURLを使用します。
nvm npm_mirror [url] : npmのミラーを設定します。デフォルトはhttps://github.com/npm/cli/archive/です。[url]を空欄にするとデフォルトURLを使用します。
nvm uninstall <version> : バージョンは特定のバージョンを指定する必要があります。
nvm upgrade : nvmを最新バージョンに更新します。アップグレード後7日間は手動でロールバック可能です。
nvm use [version] [arch] : 指定したバージョンを使用します。"latest"、"lts"、"newest"も指定可能です。
"newest"はインストール済みの最新バージョンです。オプションで32/64ビットアーキテクチャを指定できます。
nvm use <arch>で選択中のバージョンをそのままに、32/64ビットモードのみ切り替えます。
nvm reinstall <version> : 特定バージョンをクリーンインストールし直すショートカットです。
nvm root [path] : nvmがnode.jsの各バージョンを保存するディレクトリを設定します。
<path>を指定しない場合は現在のrootを表示します。
nvm subscribe [--]<topic> : デスクトップ通知を購読します。
有効なトピック: lts, current, nvm4w, author
nvm unsubscribe [--]<topic> : デスクトップ通知の購読を解除します。
有効なトピック: lts, current, nvm4w, author
nvm [--]version : 現在実行中のnvm for Windowsのバージョンを表示します。vも同じ意味です。
インストールしたnode.jsの配置場所
nvmの設定ファイルにパスが記載されている;
> type C:\Users\<ユーザ名>\AppData\Local\nvm\settings.txt root: C:\Users\<ユーザ名>\AppData\Local\nvm path: C:\nvm4w\nodejs
root のパスの中にバージョンごとにフォルダが作られて、そこに実体が保存される。
path のパスがその実体があるフォルダへのシンボリックリンクになっている。
> dir C:\Users\<ユーザ名>\AppData\Local\nvm
Directory: C:\Users\<ユーザ名>\AppData\Local\nvm
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2025/06/15 5:53 v22.16.0
d---- 2026/02/11 21:32 v24.13.1
-a--- 2025/01/01 3:02 20502 alert.ico
...
> ls C:\nvm4w\
Directory: C:\nvm4w
Mode LastWriteTime Length Name
---- ------------- ------ ----
l---- 2026/02/11 22:21 nodejs -> C:\Users\<ユーザ名>\AppData\Local\nvm\v24.13.1
以上。