Skip to content

Commit d2bff8d

Browse files
committed
🔖 Nodejs 安装脚本和文档
1 parent 7f887c5 commit d2bff8d

4 files changed

Lines changed: 80 additions & 10 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
4141
### 常见软件安装配置详述
4242

43-
> CODES:安装配置脚本,按照说明即可安装使用。
43+
> *`CODES`:安装配置脚本,按照说明安装使用即可。*
4444
>
45-
> DOCS: 安装配置文档,说明安装的方法以及一些注意事项。
45+
> *`DOCS`: 安装配置文档,说明安装的方法以及一些注意事项。*
4646
4747
* JDK 安装和配置:| [CODES](codes/deploy/tool/jdk) | [DOCS](docs/deploy/tool/jdk/install-jdk.md) |
4848
* Maven 安装和配置:| [CODES](codes/deploy/tool/maven) | [DOCS](docs/deploy/tool/maven/install-maven.md) |
4949
* Nginx 安装和配置:| [CODES](codes/deploy/tool/nginx) | [DOCS](docs/deploy/tool/nginx/install-nginx.md) |
50-
50+
* Nodejs 安装和配置:| [CODES](codes/deploy/tool/nodejs) | [DOCS](docs/deploy/tool/nodejs/install-nodejs.md) |

codes/deploy/tool/nodejs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 安装 Nodejs
2+
3+
使用方法:
4+
5+
```sh
6+
wget --no-check-certificate --no-cookies https://raw.githubusercontent.com/dunwu/linux/master/codes/deploy/tool/nodejs/install-nodejs.sh
7+
chmod -R 777 install-nodejs.sh
8+
./install-nodejs.sh
9+
```
Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
#!/usr/bin/env bash
22

3-
echo -e "\n>>>>>>>>> install Node.js"
3+
###################################################################################
4+
# 安装 Nodejs 脚本
5+
# 适用于所有 linux 发行版本。
6+
# Author: Zhang Peng
7+
###################################################################################
48

5-
# 安装 nvm
6-
rm -rf ~/.nvm
7-
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm
8-
source ~/.nvm/nvm.sh
9+
echo -e "\n>>>>>>>>> install node.js"
910

10-
# 使用 nvm 安装 Node 指定版本
11-
nvm install 8.9.4
11+
. ~/.nvm/nvm.sh
12+
nvm --version
13+
execode=$?
14+
if [ ${execode} != 0 ]; then
15+
echo -e "\n未找到 nvm ,开始安装"
16+
echo -e "\n>>>>>>>>> install nvm"
17+
rm -rf ~/.nvm
18+
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
19+
. ~/.nvm/nvm.sh
20+
nvm --version
21+
fi
22+
23+
version=8.9.4
24+
nvm install ${version}
25+
nvm use ${version}
26+
node --version
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Nodejs 安装
2+
3+
## 安装方法
4+
5+
### 先安装 nvm
6+
7+
推荐安装 nvm(Node Version Manager) ,来管理 node.js 版本。
8+
9+
安装步骤如下:
10+
11+
(1)执行安装脚本
12+
13+
```
14+
rm -rf ~/.nvm
15+
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
16+
. ~/.nvm/nvm.sh
17+
```
18+
19+
(2)检验是否安装成功
20+
21+
执行 `nvm --version` 命令。
22+
23+
注意:如果出现 `nvm: command not found` ,关闭终端,然后再打开终端试试。
24+
25+
### 安装 Nodejs
26+
27+
安装步骤如下:
28+
29+
(1)使用 nvm 安装 nodejs 指定版本
30+
31+
执行以下命令:
32+
33+
```
34+
nvm install 8.9.4
35+
nvm use 8.9.4
36+
```
37+
38+
(2)检验是否安装成功
39+
40+
执行 `node --version` 命令。
41+
42+
注意:如果出现 `node: command not found` ,关闭终端,然后再打开终端试试。
43+
44+
## 脚本
45+
46+
| [安装脚本](https://github.com/dunwu/linux/tree/master/codes/deploy/tool/nodejs) |

0 commit comments

Comments
 (0)