Appearance
Install Node.js on Linux
Node.js is required for running tools like CodeX CLI, Gemini CLI, and CC-Switch.
Method 1: Using fnm (Recommended)
fnm (Fast Node Manager) is the recommended way to install and manage Node.js versions.
Install fnm
bash
curl -fsSL https://fnm.vercel.app/install | bashRestart your terminal or source your profile:
bash
source ~/.bashrcInstall Node.js
bash
fnm install --lts
fnm use lts-latest
fnm default lts-latestVerify
bash
node -v
npm -vMethod 2: Using NodeSource Repository
Ubuntu / Debian
bash
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejsRHEL / CentOS / Fedora
bash
curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -
sudo yum install -y nodejsVerify
bash
node -v
npm -vMethod 3: Using nvm
bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bashRestart your terminal, then:
bash
nvm install --lts
nvm use --ltsMethod 4: Using Package Manager
WARNING
System package managers often have outdated Node.js versions. Use fnm or NodeSource for the latest LTS version.
Ubuntu / Debian
bash
sudo apt update
sudo apt install nodejs npmArch Linux
bash
sudo pacman -S nodejs npmTroubleshooting
node: command not found
- Restart your terminal after installation
- Check your PATH:
echo $PATH - For fnm: ensure
eval "$(fnm env --use-on-cd)"is in your~/.bashrc
Permission Errors with Global Installs
Instead of using sudo npm install -g, configure npm to use a user directory:
bash
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc