LoginSignup
2
4

More than 5 years have passed since last update.

windows10でnode.jsのバージョンを切り替えて使う( nvm-windows )

Posted at

はじめに

windowsでnode.jsをバージョン切り替えながら使うためにnvm-windowsをインストールすることで解決できます。

nvm-windowsの入手

github: https://github.com/coreybutler/nvm-windows/releases
こちらの、nvm-setup.zipをダウンロードしてきて解凍、インストールします。

コマンドプロンプトで実行

バージョンの確認とヘルプ

> nvm
Running version 1.1.6.

Usage:

  nvm arch                     : Show if node is running in 32 or 64 bit mode.
  nvm install <version> [arch] : The version can be a node.js version or "latest" for the latest stable 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/npm/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 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.

インストール可能なバージョンの確認

> nvm list available

次のように結果が表示されます。

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|   10.12.0    |    8.12.0    |   0.12.18    |   0.11.16    |
|   10.11.0    |    8.11.4    |   0.12.17    |   0.11.15    |
|   10.10.0    |    8.11.3    |   0.12.16    |   0.11.14    |
|    10.9.0    |    8.11.2    |   0.12.15    |   0.11.13    |
|    10.8.0    |    8.11.1    |   0.12.14    |   0.11.12    |
|    10.7.0    |    8.11.0    |   0.12.13    |   0.11.11    |
|    10.6.0    |    8.10.0    |   0.12.12    |   0.11.10    |
|    10.5.0    |    8.9.4     |   0.12.11    |    0.11.9    |
|    10.4.1    |    8.9.3     |   0.12.10    |    0.11.8    |
|    10.4.0    |    8.9.2     |    0.12.9    |    0.11.7    |
|    10.3.0    |    8.9.1     |    0.12.8    |    0.11.6    |
|    10.2.1    |    8.9.0     |    0.12.7    |    0.11.5    |
|    10.2.0    |    6.14.4    |    0.12.6    |    0.11.4    |
|    10.1.0    |    6.14.3    |    0.12.5    |    0.11.3    |
|    10.0.0    |    6.14.2    |    0.12.4    |    0.11.2    |
|    9.11.2    |    6.14.1    |    0.12.3    |    0.11.1    |
|    9.11.1    |    6.14.0    |    0.12.2    |    0.11.0    |
|    9.11.0    |    6.13.1    |    0.12.1    |    0.9.12    |
|    9.10.1    |    6.13.0    |    0.12.0    |    0.9.11    |
|    9.10.0    |    6.12.3    |   0.10.48    |    0.9.10    |

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

最新のバージョンをインストールする

> nvm install lasted
Downloading node.js version 10.12.0 (64-bit)...
Complete
Creating C:\Users\user\AppData\Roaming\nvm\temp

Downloading npm version 6.4.1... Download failed. Rolling Back.
Rollback failed. remove C:\Users\user\AppData\Roaming\nvm\temp\npm-v6.4.1.zip: The process cannot access the file because it is being used by another process.
Could not download npm for node v10.12.0.
Please visit https://github.com/npm/npm/releases/tag/v6.4.1 to download npm.
It should be extracted to C:\Users\user\AppData\Roaming\nvm\v10.12.0

現在インストール済みのnode.jsを確認する

> nvm list
    10.12.0
    10.7.0
  * 10.5.0 (Currently using 64-bit executable)
    7.9.0

node.jsのバージョンの切り替えを行う

> nvm use 10.7.0

管理者権限によって切り替えていいかダイアログが表示するので、「はい」を選択すると指定したバージョンに切り替わります。

Now using node v10.7.0 (64-bit)

nodeコマンドでnode.jsバージョンの確認

> node -v
v10.7.0

ということで

あとは自由にバージョン切り替えをしつつnode.jsを利用できます。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4