This guide provides a clear, step-by-step process for installing Node.js on a Linux system, including configuring a domestic npm registry for faster package downloads. Ideal for developers setting up their environment.
1. Get the installation package
The installation package is located in the /root/Downloads/ directory, and the compressed package name is: node-v18.14.0-linux-x64.tar.xz
2. Unzip the installation:
Unzip to /usr/local/lib/nodejs. After unzipping, the path is /usr/local/lib/nodejs/node-v18.14.0-linux-x64
Create a nodejs directory in the /usr/local/lib directory:
mkdir -p /usr/local/lib/nodejs
Unzip the file node-v18.14.0-linux-x64.tar.xz in the /root/Downloads/ directory to /usr/local/lib/nodejs/
tar -xf /root/Downloads/node-v18.14.0-linux-x64.tar.xz -C /usr/local/lib/nodejs/
3. Add to PATH file
# nodejs environment
export PATH=$PATH:/usr/local/lib/nodejs/node-v18.14.0-linux-x64/bin
4. Configure domestic source
npm config set registry https://registry.npmmirror.com