66
77## 安装 nvm
88
9- > ** 安装前请保证电脑已经正确安装并配置好了Oh -My-Zsh。**
9+ > ** 安装前请保证电脑已经正确安装并配置好了 Oh -My-Zsh。**
1010
1111安装可以参考[ nvm] ( https://github.com/nvm-sh/nvm ) 项目的 README 文档,可以在下面的命令二选一条在终端执行。
1212
1313::: code-group
1414
15- ``` bash [国内镜像加速]
15+ ``` shell [国内镜像加速]
1616# 使用 wget 命令安装
1717wget -qO- https://raw.gitmirror.com/nvm-sh/nvm/v0.40.1/install.sh | bash
1818
1919# 使用 curl 命令安装
2020curl -o- https://raw.gitmirror.com/nvm-sh/nvm/v0.40.1/install.sh | bash
21- ````
21+ ```
2222
23- ` ` ` bash [GitHub]
23+ ``` shell [GitHub]
2424# 使用 wget 命令安装
2525wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
2626
2727# 使用 curl 命令安装
2828curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
2929```
30+
3031:::
3132
3233如果安装并配置好了 Oh-My-Zsh 终端的话,默认自动将对应的配置写入了 ` ~/.bash_profile ` , ` ~/.zshrc ` , ` ~/.profile ` 或 ` ~/.zshrc ` 文件中,内容为:
3334
34- ` ` ` bash
35+ ``` shell
3536export NVM_DIR=" $( [ -z " ${XDG_CONFIG_HOME-} " ] && printf %s " ${HOME} /.nvm" || printf %s " ${XDG_CONFIG_HOME} /nvm" ) "
3637[ -s " $NVM_DIR /nvm.sh" ] && \. " $NVM_DIR /nvm.sh" # This loads nvm
3738```
@@ -44,43 +45,44 @@ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || pr
4445
4546### 查看可供使用稳定版本
4647
47- ` ` ` bash
48+ ``` shell
4849nvm ls-remote
4950```
5051
5152> NodeJS 的版本发布很频繁,一般可以在[ NodeJS 官网] ( https://nodejs.org/en/ ) 看到 LTS 版本进行下载。
5253
5354### 查看本地已经有的 NodeJS
5455
55- ` ` ` bash
56+ ``` shell
5657nvm list
5758```
5859
5960### 安装指定版本的 NodeJS
6061
61- ` ` ` bash
62+ ``` shell
6263nvm install v16.19.1
6364```
6465
6566### 指定默认的 NodeJS 版本
6667
67- ` ` ` bash
68+ ``` shell
6869nvm alias default v16.19.1 # 指定默认的NodeJS版本
6970nvm use default
7071```
71- > 如果是切换不同版本的node,请确保对应的依赖已经安装,比如` yarn` ,因为不同版本的node,对应的bin目录不一致,目录为:` ~/.nvm/versions/node/v16.19.1/bin` 。
72+
73+ > 如果是切换不同版本的 node,请确保对应的依赖已经安装,比如` yarn ` ,因为不同版本的 node,对应的 bin 目录不一致,目录为:` ~/.nvm/versions/node/v16.19.1/bin ` 。
7274
7375### 查看系统当前使用的 NodeJS 版本
7476
75- ` ` ` bash
77+ ``` shell
7678nvm current
7779```
7880
79- > nvm管理的node安装的目录在 ` ~/.nvm/versions/node/` 下。
81+ > nvm 管理的 node 安装的目录在 ` ~/.nvm/versions/node/ ` 下。
8082
8183### 卸载指定的 NodeJS 版本
8284
83- ` ` ` bash
85+ ``` shell
8486nvm uninstall v16.19.1 // 卸载v16.19.1
8587```
8688
@@ -92,7 +94,7 @@ nvm uninstall v16.19.1 // 卸载v16.19.1
9294
9395### 安装
9496
95- ` ` ` bash
97+ ``` shell
9698npm install -g nrm
9799```
98100
@@ -102,18 +104,19 @@ npm install -g nrm
102104
103105#### 查看可用源
104106
105- ` ` ` bash
107+ ``` shell
106108nrm ls
107109```
110+
108111#### 使用指定源
109112
110- ` ` ` bash
113+ ``` shell
111114nrm use taobao
112115```
113116
114117#### 检查当前使用源
115118
116- ` ` ` bash
119+ ``` shell
117120nrm current
118121```
119122
@@ -123,9 +126,7 @@ nrm current
123126
124127[ ` yarn ` ] ( https://yarnpkg.com/ ) 是一个快速、可靠、安全的依赖管理工具。
125128
126- ` ` ` bash
127-
128- ` ` ` bash
129+ ``` shell
129130npm -g install yarn
130131```
131132
@@ -139,7 +140,7 @@ npm -g install bun
139140
140141## 安装全局依赖
141142
142- ``` bash
143+ ``` shell
143144yarn global add cross-env live-server
144145```
145146
0 commit comments