1. 下载地址
curl -O https://nodejs.org/dist/v16.18.0/node-v16.18.0-linux-x64.tar.xz
2. 安装部署
VERSION=v16.18.0
DISTRO=linux-x64
mkdir -p /usr/local/lib/nodejs
tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs
3. 添加环境变量
cat >> ~/.profile <<'EOF'
# Nodejs
VERSION=v16.18.0
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH
EOF
source ~/.profile
4. 验证安装程序
[root@Python nodejs]# node -v
v16.18.0
[root@Python nodejs]# npm version
{
npm: '8.19.2',
node: '16.18.0',
v8: '9.4.146.26-node.22',
uv: '1.43.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.18.1',
modules: '93',
nghttp2: '1.47.0',
napi: '8',
llhttp: '6.0.10',
openssl: '1.1.1q+quic',
cldr: '41.0',
icu: '71.1',
tz: '2022b',
unicode: '14.0',
ngtcp2: '0.8.1',
nghttp3: '0.7.0'
}
[root@Python nodejs]# npx -v
8.19.2
END