windowsでのNode.js バージョン管理

NVM(Node Version Manager)は、Node.jsを複数インストールして使い分けるためのソフトウェアで、Aboutには以下のような記載があります

nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.

windowsでは、WSLでしかどうさしないです
そのため、windowsでは直接公式のnvmを使うことができないです

そこで変わりのものとして、nvm-windowsが有名なようなので、そちらをインストールしてみました
自分は、nvm-setup.zipでインストールしました

現在のバージョンは以下の通り

c:\>nvm --version
1.1.12

使い方のメモ

ヘルプ

c:\>nvm --helop

Running version 1.1.12.

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 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 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 [--]version              : Displays the current running version of nvm for Windows. Aliased as v.

バージョン

c:\>nvm --version
1.1.12

インストール可能な一覧

c:\>nvm list available

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    23.1.0    |   22.11.0    |   0.12.18    |   0.11.16    |
|    23.0.0    |   20.18.0    |   0.12.17    |   0.11.15    |
|   22.10.0    |   20.17.0    |   0.12.16    |   0.11.14    |
|    22.9.0    |   20.16.0    |   0.12.15    |   0.11.13    |
|    22.8.0    |   20.15.1    |   0.12.14    |   0.11.12    |
|    22.7.0    |   20.15.0    |   0.12.13    |   0.11.11    |
|    22.6.0    |   20.14.0    |   0.12.12    |   0.11.10    |
|    22.5.1    |   20.13.1    |   0.12.11    |    0.11.9    |
|    22.5.0    |   20.13.0    |   0.12.10    |    0.11.8    |
|    22.4.1    |   20.12.2    |    0.12.9    |    0.11.7    |
|    22.4.0    |   20.12.1    |    0.12.8    |    0.11.6    |
|    22.3.0    |   20.12.0    |    0.12.7    |    0.11.5    |
|    22.2.0    |   20.11.1    |    0.12.6    |    0.11.4    |
|    22.1.0    |   20.11.0    |    0.12.5    |    0.11.3    |
|    22.0.0    |   20.10.0    |    0.12.4    |    0.11.2    |
|    21.7.3    |    20.9.0    |    0.12.3    |    0.11.1    |
|    21.7.2    |   18.20.4    |    0.12.2    |    0.11.0    |
|    21.7.1    |   18.20.3    |    0.12.1    |    0.9.12    |
|    21.7.0    |   18.20.2    |    0.12.0    |    0.9.11    |
|    21.6.2    |   18.20.1    |   0.10.48    |    0.9.10    |

This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases

全てが見たい場合は、https://nodejs.org/en/download/releasesとのこと

インストールしたいバージョンが特に決まっていなければこちらから選ぶ形になります

インストール

22.11.0のバージョンをインストールしてみます

c:\>nvm install 22.11.0
Downloading node.js version 22.11.0 (64-bit)...
Extracting node and npm...
Complete
npm v10.9.0 installed successfully.


Installation complete. If you want to use this version, type

nvm use 22.11.0

インストールしてあるnode.jsの一覧

c:\>nvm list

    22.11.0
  * 20.18.0 (Currently using 64-bit executable)
  • がついているのが現在選択されているnode.jsのバージョンです

バージョンの切り替え

c:\>nvm use 22.11.0
Now using node v22.11.0 (64-bit)

※プロンプトを管理者権限ありで起動していないと、変更時にユーザーアカウント制御のダイアログが表示されます

選択中のバージョン

c:\>nvm current
v22.11.0
投稿日時: 2024-11-09 11:16:09
更新日時: 2024-11-09 11:57:09

最近の投稿

タグ

アーカイブ

その他