theboyaply
theboyaply
发布于 2022-01-05 / 399 阅读
0
0

Linux安装node

下载安装包

中文官网:http://nodejs.cn/download/

Linux可根据系统版本对应安装包,比如:Linux 二进制文件 (x64)选项下载出来的就是node-v16.13.1-linux-x64.tar.xz(当前最新版本)。

解压

$ tar xf node-v16.13.1-linux-x64.tar.xz
$ mv node-v16.13.1-linux-x64 node

配置环境变量

编辑/etc/profile文件,在末尾添加:

export PATH=/xxx/node/bin:$PATH

保存后重新加载profile文件即可(命令:source /etc/profile)。

可使用命令node -v输出版本检查是否成功。

使用问题

如果在使用时报错:/usr/bin/env: node: No such file or directory,可以试试加一个软链接:

$ ln -s "$(which node)" /usr/bin/node

-- end --


评论