doc: update docs/nvm.md (#512)

This commit is contained in:
jaywcjlove 2024-03-22 06:18:15 +08:00
parent f8b4ef611f
commit 8ce7714bca
5 changed files with 153 additions and 113 deletions

View File

@ -126,7 +126,7 @@ Quick Reference
[PM2](./docs/pm2.md)<!--rehype:style=background: rgb(73 117 241);&class=contributing-->
[package.json](./docs/package.json.md)<!--rehype:style=background: rgb(132 132 132);-->
[Yarn](./docs/yarn.md)<!--rehype:style=background: rgb(33 136 182);-->
[nvm windows](./docs/nvm-windows.md)<!--rehype:style=background: rgb(132 132 132);-->
[nvm](./docs/nvm.md)<!--rehype:style=background: rgb(132 132 132);-->
<!--rehype:class=home-card-->
## 工具

View File

@ -1,9 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" fill="currentColor" height="1em"
width="1em">
<g>
<path
d="M499.8 990c-12.6 0-25.2-3.4-36.4-10.1l-115.9-71c-17.3-10-8.8-13.6-3.2-15.6 23.1-8.3 30-12.4 54.6-26.9 2.6-1.5 6-.9 8.7.7l86.9 51.4c3.2 1.9 7.8 1.9 10.8 0l339.5-201.8c3.2-1.9 5.3-5.8 5.3-9.7V298.5c0-4-2.1-7.9-5.4-9.9L505.3 81.5c-3.2-2-7.5-2-10.7 0L155.5 288.6c-3.4 2-5.5 5.9-5.5 9.8V707c0 4 2.1 7.7 5.4 9.6l87.3 52.4c51.6 26.7 82.2-.4 82.2-32V335.3c0-5.8 4.5-10.3 10.1-10.3h49.9c5.5 0 10.1 4.5 10.1 10.3v401.8c0 71.2-42.3 112.1-107.6 112.1-20 0-35.9 0-80-22.5l-91-54.2C93.9 759.1 80 734 80 707.1V292.6c0-26.9 13.9-52 36.5-65.4L463.6 19.6c21.9-12.9 51.1-12.9 72.9 0l347 207.5c22.5 13.5 36.5 38.6 36.5 65.4V707c0 26.9-13.9 52-36.5 65.5l-347 207.3c-11.1 6.6-23.7 10.1-36.5 10.1l-.2.1z" />
<path
d="M607.1 710c-141.3 0-183.8-69.1-183.8-129.7 0-5.8 4.5-10.3 10-10.3h44.9c5 0 9.2 3.7 10 8.8 6.7 47.3 36.6 68.1 118.8 68.1 73.1 0 103-22.6 103-62.7 0-23.2-7.6-40.3-121.2-51.8-95-9.7-153.8-31.4-153.8-110 0-72.5 59.1-114.8 158-114.8 100.9 0 167.3 30.6 173.2 111.2.2 2.9-.8 5.8-2.7 8-1.9 2.1-4.5 3.3-7.3 3.3h-45c-4.7 0-8.8-3.4-9.8-8.1-9.6-37.1-37.1-51.2-108.4-51.2-79.8 0-89.1 27.9-89.1 49.5 0 26.2 11 33.8 118.8 48.5C729.3 483.2 780 503.9 780 581.4c0 78.3-63.1 128.6-172.9 128.6z" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

6
assets/nvm.svg Normal file
View File

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" fill="currentColor" height="1em" width="1em">
<g>
<path d="M499.8 990c-12.6 0-25.2-3.4-36.4-10.1l-115.9-71c-17.3-10-8.8-13.6-3.2-15.6 23.1-8.3 30-12.4 54.6-26.9 2.6-1.5 6-.9 8.7.7l86.9 51.4c3.2 1.9 7.8 1.9 10.8 0l339.5-201.8c3.2-1.9 5.3-5.8 5.3-9.7V298.5c0-4-2.1-7.9-5.4-9.9L505.3 81.5c-3.2-2-7.5-2-10.7 0L155.5 288.6c-3.4 2-5.5 5.9-5.5 9.8V707c0 4 2.1 7.7 5.4 9.6l87.3 52.4c51.6 26.7 82.2-.4 82.2-32V335.3c0-5.8 4.5-10.3 10.1-10.3h49.9c5.5 0 10.1 4.5 10.1 10.3v401.8c0 71.2-42.3 112.1-107.6 112.1-20 0-35.9 0-80-22.5l-91-54.2C93.9 759.1 80 734 80 707.1V292.6c0-26.9 13.9-52 36.5-65.4L463.6 19.6c21.9-12.9 51.1-12.9 72.9 0l347 207.5c22.5 13.5 36.5 38.6 36.5 65.4V707c0 26.9-13.9 52-36.5 65.5l-347 207.3c-11.1 6.6-23.7 10.1-36.5 10.1l-.2.1z" />
<path d="M607.1 710c-141.3 0-183.8-69.1-183.8-129.7 0-5.8 4.5-10.3 10-10.3h44.9c5 0 9.2 3.7 10 8.8 6.7 47.3 36.6 68.1 118.8 68.1 73.1 0 103-22.6 103-62.7 0-23.2-7.6-40.3-121.2-51.8-95-9.7-153.8-31.4-153.8-110 0-72.5 59.1-114.8 158-114.8 100.9 0 167.3 30.6 173.2 111.2.2 2.9-.8 5.8-2.7 8-1.9 2.1-4.5 3.3-7.3 3.3h-45c-4.7 0-8.8-3.4-9.8-8.1-9.6-37.1-37.1-51.2-108.4-51.2-79.8 0-89.1 27.9-89.1 49.5 0 26.2 11 33.8 118.8 48.5C729.3 483.2 780 503.9 780 581.4c0 78.3-63.1 128.6-172.9 128.6z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,103 +0,0 @@
nvm-windows 备忘清单
===
[nvm-windows](https://github.com/coreybutler/nvm-windows) 是一个用于管理windows电脑上多个node.js版本的程序
<!--rehype:style=padding-top: 12px;-->
入门
-----
### 安装
最新的node-windows可以通过[nvm-windows发行版下载](https://github.com/coreybutler/nvm-windows/releases)地址下载安装程序
双击setup程序按照提示操作即可完成安装。
### 常用指令
展示当前使用版本
```
nvm current
```
安装指定版本的node程序版本version设置为"latest"安装最新版本或者设置为"lts"安装最近的LTS长期支持版本。arch可以指定32或者64位版本默认跟随系统设置为"all"同时安装32和64位版本。在命令最后添加--insecure将跳过远程下载服务器的SSL验证。
```
nvm install <version> [arch]
```
列出node.js已安版本。可选输入 available 显示可获取的版本下载列表。
```
nvm list [available]
```
卸载指定版本
```
nvm uninstall <version>
```
切换使用指定版本。version可选设置latest、lts以及newest,启用newest指定最近安装版本。arch可选指定32/64位架构。nvm use <arch>将继续使用当前版本,但是将切换为指定架构程序。
```
nvm use <version> [arch]
```
### 基础指令
管理应用程序状态很简单,这里是命令
查看node程序是运行在32位还是64位模式下指定32或者64覆盖默认运行架构模式
```
nvm arch [32|64]
```
检查NVM4W进程已知问题
```
nvm check
```
启用node.js版本管理
```
nvm on
```
关闭node.js版本管理。不会执行任何卸载操作
```
nvm off
```
设置下载代理。可选url留空查看当前使用代理设置为"none"移除代理设置。
```
nvm proxy [url]
```
设置nvm储存不同版本的node.js的目录。如果未设置path将展示当前存储目录。
```
nvm root <path>
```
展示当前nvm-windows使用版本。
```
nvm version
```
指定node镜像
```
nvm node_mirror <node_mirror_url>
```
指定npm镜像
```
nvm npm_mirror <npm_mirror_url>
```

146
docs/nvm.md Normal file
View File

@ -0,0 +1,146 @@
nvm 备忘清单
===
nvm 是一个用于管理电脑上多个 node.js 版本的程序
<!--rehype:style=padding-top: 12px;-->
入门
-----
### 安装
<!--rehype:wrap-class=row-span-5-->
Node Version Manager 用于管理多个活动的 Node.js 版本
- [Windows 版本](https://github.com/coreybutler/nvm-windows/releases) _(github.io)_
- [Posix 兼容的 Shell 版本](https://github.com/nvm-sh/nvm?tab=readme-ov-file) _(github.io)_
#### Windows
最新的 windows 版本通过 [nvm-windows发行版下载](https://github.com/coreybutler/nvm-windows/releases) 地址下载安装程序
双击 `setup` 程序按照提示操作即可完成安装。
#### macOS/Linux
```shell
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
```
<!--rehype:className=wrap-text-->
```shell
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
```
<!--rehype:className=wrap-text-->
#### 快速使用
```shell
# 下载并安装 Node.js 20 版本
nvm install 20
# 验证环境中的 Node.js 版本是否正确
node --version # 应该打印“v20.11.1”
# 验证环境中是否存在正确的 NPM 版本
npm --version # 应该打印“10.2.4”
```
### 展示当前使用版本
```shell
nvm current
```
### 安装指定版本的 node 程序
<!--rehype:wrap-class=row-span-2-->
version 设置为 `latest` 安装最新版本或者设置为 "lts" 安装最近的 LTS长期支持版本。
```shell
nvm install <version> [arch]
```
`arch` 可以指定 `32` 或者 `64` 位版本(默认跟随系统),设置为 `all` 同时安装 32 和 64 位版本。在命令最后添加 `--insecure` 将跳过远程下载服务器的 SSL 验证。
### 切换使用指定版本
```shell
nvm use <version> [arch]
```
### 列出 node.js 已安版本
可选输入 available 显示可获取的版本下载列表。
```shell
nvm list [available]
```
### 卸载指定版本
<!--rehype:wrap-class=row-span-2-->
```shell
# <version> 可选设置 latest/lts/newest
nvm uninstall <version>
```
启用 `newest` 指定最近安装版本。
```shell
nvm use <arch> # 可选指定32/64位架构
```
将继续使用当前版本,但是将切换为指定架构程序。
### 查看 node 运行模式
```shell
nvm arch [32|64]
```
查看 node 程序是运行在 `32` 位还是 `64` 位模式下,指定 `32` 或者 `64` 覆盖默认运行架构模式
### 检查 NVM4W 进程已知问题
```shell
nvm check
```
### 启用/关闭 node.js 版本管理
```shell
nvm on # 启用
nvm off # 关闭 - 不会执行任何卸载操作
```
### 设置下载代理
```shell
nvm proxy [url]
```
可选 url 留空查看当前使用代理,设置为 "none" 移除代理设置。
### 设置版本存储目录
设置 nvm 储存不同版本的 node.js 的目录。如果未设置path将展示当前存储目录。
```shell
nvm root <path>
```
### 展示当前 nvm 使用版本
```shell
nvm version
```
### 指定 node 镜像
```shell
nvm node_mirror <node_mirror_url>
```
### 指定 npm 镜像
```shell
nvm npm_mirror <npm_mirror_url>
```