Skip to content

Install Node.js on Linux

Node.js is required for running tools like CodeX CLI, Gemini CLI, and CC-Switch.

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 | bash

Restart your terminal or source your profile:

bash
source ~/.bashrc

Install Node.js

bash
fnm install --lts
fnm use lts-latest
fnm default lts-latest

Verify

bash
node -v
npm -v

Method 2: Using NodeSource Repository

Ubuntu / Debian

bash
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

RHEL / CentOS / Fedora

bash
curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -
sudo yum install -y nodejs

Verify

bash
node -v
npm -v

Method 3: Using nvm

bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

Restart your terminal, then:

bash
nvm install --lts
nvm use --lts

Method 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 npm

Arch Linux

bash
sudo pacman -S nodejs npm

Troubleshooting

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

3xCoder — Unified AI API Endpoint