Linux platform
For Linux servers, it is recommended to use the one-click script on this site to install Node.js v22 LTS. The script only handles Node.js, npm and npx environments and does not configure Claude, Codex or any API Key.
Recommendation: One-click installation
Execute in Terminal:
curl -fsSL https://docs.muskapi.cc/scripts/install-node.sh | bash
or:
wget -qO- https://docs.muskapi.cc/scripts/install-node.sh | bash
If your installation is slow in a domestic network environment, the script will prompt whether to use a domestic image by default. It can also be specified explicitly:
INSTALL_MIRROR=cn curl -fsSL https://docs.muskapi.cc/scripts/install-node.sh | bash
Basic check
After the installation is complete, reopen the terminal and check the current environment:
node -v
npm -v
npx -v
which node
If Node.js does not exist or the version is lower than 22, please re-execute the one-click script, or manually install LTS according to your distribution.
Alternate: Ubuntu/Debian
LTS can be installed using NodeSource:
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs
node -v
npm -v
If there is an old version of Node.js in the system, it is recommended to confirm the source first:
which node
apt-cache policy nodejs
Alternate: CentOS/Rocky/AlmaLinux
You can use release modules or NodeSource. Take NodeSource as an example:
curl -fsSL https://rpm.nodesource.com/setup_22.x | bash -
yum install -y nodejs
node -v
npm -v
Systems using dnf can replace yum with dnf.
Use nvm
If this machine is mainly used for development, you can also use nvm to manage versions:
nvm install 22
nvm use 22
node -v
When using nvm on the server, be aware that systemd, cron, and ssh non-interactive shells may not automatically load the nvm environment.
Server usage recommendations
- Write the source of environment variables clearly in the script and do not rely on temporary terminal status.
- Use systemd, pm2 or supervisor for long-running services.
- Multi-user servers do not write the API Key to the global profile.
- When encountering permission problems, first check the installation directory and current user. Do not directly add 777 permissions to all files.