knowledge/docs/frontend/在linux中安装node二进制文件.md

43 lines
712 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 在linux中安装node二进制文件
### 下载二进制文件
下载网址 <https://nodejs.org/zh-cn/download/>
备用中文网址 <https://nodejs.cn/download/>
以18.16.1版本为例
```sh
wget https://npmmirror.com/mirrors/node/v18.16.1/node-v18.16.1-linux-x64.tar.xz
```
### 安装
先创建安装目录并解压文件
```sh
sudo mkdir -p /usr/local/lib/nodejs
tar xJvf node-v18.16.1-linux-x64.tar.xz -C /usr/local/lib/nodejs
```
再将node执行目录写入/etc/profile在`export PATH`的上一行添加:
```profile
PATH=/usr/local/lib/nodejs/node-v18.16.1-linux-x64/bin:$PATH
```
重新加载profile
```sh
source /etc/profile
```
安装完成!
查看版本
```sh
node -v
npm -v
```