nvm的使用

nvm不是一个npm插件,它需要去官网下载。

nvm官网地址:https://nvm.uihtm.com/

如下nvm官网长这样,点击如图下载windows,作者是windows就点这个下载,mac点右边那个。

image.png

会下载一个.exe文件,一直点击下一步就安装好了,好了之后使用nvm v或者nvm -v验证是否安装好了,出现具体版本号就安装好了,如下:

nvm help呼出使用手册:

nvm arch                     : Show if node is running in 32 or 64 bit mode.
  nvm current                  : Display active version.
  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.

如何理解使用手册里面的[],跟<>符号,且看如下举例:

[]代表可选项

例如:nvm list [available]

它给的解释是:List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.

翻译过来如下:列出node.js安装。在末尾输入“available”,看看可以安装什么。别名为ls。

口水话翻译:available为一个可选单词,你可以nvm list也可以nvm list available,但是nvm list available表示可以安装什么版本。

执行nvm list available显示的可安装版本,其中CURRENT是最新版,LTS是稳定版,如下:


执行nvm list是已安装的版本,如下:
image.png

<>代表变量,为必传变量不传报错

例如:nvm install <version> [arch]

他给的意思翻译过来是:
版本可以是一个特定的版本,“latest”表示最新的当前版本,或者“lts”表示
最新的LTS版本。可选地指定是安装32位还是64位版本(默认值)
到系统拱)。设置[arch]为"all"安装32位和64位版本。
在此命令的末尾添加——insecure,以绕过远程下载服务器的SSL验证。

口水话翻译:nvm install latest安装最新版,nvm install lts安装稳定的最新版,nvm install lts all安装稳定的32与64位版本。

<version>是一个变量,必传,不传报错:


<version>可以为18.12.0这样的值,也可以为latest或者lts

[arch]为可选传入,可以为all,也可以不传


注意事项:

node环境尽量安装结尾双数,例如目前是18.12.1是最新版,但是尽量安装18.12.0,因为单数结尾的版本容易出现问题。

不理解问题:

nvm use [version] [arch] 指令中[version]为必传,按照理解[]为可选
参考文献:
https://blog.csdn.net/langmanboy/article/details/126357952
https://zhuanlan.zhihu.com/p/550264306

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 原文地址:https://blog.csdn.net/weixin_43305450/article/detail...
    L_b115阅读 3,778评论 0 0
  • 现状是电脑没有安装node。安装nvm步骤如下: 1、终端中打开安装文件的目录: cd + ~ 2、使用git安装...
    白白胖胖呆呆阅读 3,466评论 0 0
  • 所谓nvm就是一个可以让你在同一台机器上安装和切换不同版本node的工具。 1. 下载nvm github最新版本...
    时光如剑阅读 372评论 0 13
  • 所谓nvm就是一个可以让你在同一台机器上安装和切换不同版本node的工具。 1. 下载nvm github最新版本...
    Dylan_Cao阅读 4,808评论 0 1
  • 一、为什么要使用NVM 一句话来说:在一台电脑上管理多个node版本。如果你不是个假前端,肯定遇到过某些组件限定了...
    蒙着大脸的鸵鸟阅读 769评论 0 1