windows platform nvm management node version

Installation nodejs Version Manager on Windows nvm

Download the latest nvm

Node Manager version --nvm, can run on multiple operating systems. nvm for windows is to use the go language software. My computer using a Windows operating system, so I want to install and use nvm on this operating system record.

download

Download the latest nvm-windows:
https://github.com/coreybutler/nvm-windows/releases
as shown:
Figure 1: nvm-windows version .png

I see now there are two versions of the Pre-release 1.1.6 [] and [Latest release 1.1.5], we download the current stable version 1.1.5 on it. Version 1.1.6 is the latest version, it may not be very stable.
And here there are four downloadable file.

  • nvm-noinstall.zip: This is the green version free installation, but need to be configured prior to use
  • nvm-setup.zip: This is an installation package, click Install after download, no configuration to use and convenient.
  • Source code (zip): zip compression source
  • Sourc code (tar.gz): tar.gz source, generally used for * nix

I simply use this current, for convenience, so download the nvm-set.zip file.

Installation and Upgrade

Before the operation of the installation

Note : Before installing nvm for windows, you need to uninstall any existing version of node.js. And the need to remove the existing nodejs installation directory (for example: "C: \ Program Files \ nodejs'). Because, nvm generated symlink (symbolic link / hyperlink) does not overwrite existing (even empty) installation directory .
you also need to remove an existing npm installation location (eg "C: \ Users \ weiqinl \ AppData \ Roaming \ npm"), in order to properly use nvm installation location.

installation

以上操作完成之后,双击执行下载的setup文件,
Figure 2: after double-click interface
Next之后,选择同意协议,之后选择nvm的本地安装目录,这里注意,nvm的安装路径名称中最好不要有空格。

FIG 3: nvm installation directory
例如最好不要这样有空格的~\Program Files\nvm,我这里选择的是D:\softtool\nvm
点击Next,跳转到设置 Node.js的Symlink,即需要设置nodejs的快捷方式存放的目录。
FIG 4: nodejs installation directory
之后,点击Next-->Install-->Finish完成本次安装。

检测

检查是否安装成功,我们可以在新的命令窗口中输入

nvm
  • 如果出现nvm版本号和一系列帮助指令,则说明nvm安装成功。
  • 否则,可能会提示nvm: command not found

FIG 5: nvm installed successfully detected

升级

如果要升级的话,请重新下载最新的安装程序。并直接运行安装程序。它将安全的覆盖需要更新的文件,而无需关心nodejs的安装。
此次安装需要确保和上次使用相同的安装目录。
如果你最初安装到默认位置,则只需一直点击"下一步",直到完成。

使用

nvm for windows是一个命令行工具,在控制台输入nvm,就可以看到它的命令用法。基本命令有:

  • nvm arch [32|64] : 显示node是运行在32位还是64位模式。指定32或64来覆盖默认体系结构。
  • nvm install <version> [arch]: 该可以是node.js版本或最新稳定版本latest。(可选[arch])指定安装32位或64位版本(默认为系统arch)。设置[arch]为all以安装32和64位版本。在命令后面添加--insecure ,可以绕过远端下载服务器的SSL验证。
  • nvm list [available]: 列出已经安装的node.js版本。可选的available,显示可下载版本的部分列表。这个命令可以简写为nvm ls [available]
  • nvm on: 启用node.js版本管理。
  • nvm off: 禁用node.js版本管理(不卸载任何东西)
  • nvm proxy [url]: 设置用于下载的代理。留[url]空白,以查看当前的代理。设置[url]none删除代理。
  • nvm node_mirror [url]:设置node镜像,默认为https://nodejs.org/dist/.。我建议设置为淘宝的镜像https://npm.taobao.org/mirrors/node/
  • nvm npm_mirror [url]:设置npm镜像,默认为https://github.com/npm/npm/archive/。我建议设置为淘宝的镜像https://npm.taobao.org/mirrors/npm/
  • nvm uninstall <version>: 卸载指定版本的nodejs。
  • nvm use [version] [arch]: 切换到使用指定的nodejs版本。可以指定32/64位[arch]。nvm use <arch>将继续使用所选版本,但根据提供的值切换到32/64位模式的<arch>
  • nvm root [path]: 设置 nvm 存储node.js不同版本的目录 ,如果未设置,将使用当前目录。
  • nvm version: 显示当前运行的nvm版本,可以简写为nvm v

一个nodejs的安装使用流程:

nvm ls   // 查看目前已经安装的版本
nvm install 6.10.0  // 安装指定的版本的nodejs
nvm use 6.10.0  // 使用指定版本的nodejs

这是我安装第一个版本时候的命令:

Figure 6: This is when I installed the first version of the command

认真看以下的图,相同的nvm ls命令,得到的结果为什么不一样?因为,这是使用了nvm切换到了指定的版本。如果在nvm ls命令输出了 当前样式,说明切换成功了。如果没有出现(Currently using 64-bit executable),则表示没有切换成功。这就需要查看原因,认真按照上面步骤来。
Figure 7: nvm ls shows nodejs version already installed

使用命令时注意点

  • 请用管理员身份运行命令管理器,否则可能出错。
  • 先设置nodenpm的淘宝镜像,这样成功率和下载速度会更高点。

用途

1: The main purpose, switching nodejs version. If you want to use the latest version of the popular test module you are developing, without unloading stable version of the node, you can use nvm to switch nodejs version.

important point

  • nvm installation directory, it is best not exist spaces. Otherwise, nvm can be installed successfully, but using nvm use xyz (nodejs switching) there will be problems.
  • Some global npm module may not be shared between the various versions of node.js.
    Node.js version you are using may not support some npm module. So at work Please note that the working environment.
  • Other Reference article: https://blog.csdn.net/Tyro_java/article/details/51232458

Guess you like

Origin blog.csdn.net/wangjunqiang06/article/details/80936713