Have a Question?

If you have any question you can ask below or enter what you are looking for!

How to Change Node.js Version on cPanel Terminal

Overview

Some cPanel servers include an outdated system Node.js version (often Node 10 or Node 12). Modern applications frequently require Node.js 18+, but the default shell environment may still point to the older system version.

On cPanel servers that provide CloudLinux alt-nodejs packages (e.g., alt-nodejs20), you can override the default Node and npm binaries by adding aliases to your .bashrc file. This ensures your SSH terminal always uses the correct Node.js version.

This article explains how to update your Node.js version using .bashrc aliases.

1. Check Your Current Node Version

Open the cPanel Terminal or connect via SSH:

node -v

If you see something like:

v12.x.x

…your shell is using the system Node version.

2. Locate the alt-nodejs[x] Binaries

CloudLinux provides alternative Node.js versions under:

~ ls /opt/alt/alt-nodejs

alt-nodejs10/ alt-nodejs12/ alt-nodejs16/ alt-nodejs19/ alt-nodejs22/ alt-nodejs8/
alt-nodejs11/ alt-nodejs14/ alt-nodejs18/ alt-nodejs20/ alt-nodejs6/ alt-nodejs9/

~ cd /opt/alt/alt-nodejs20/root/bin/

This directory contains:

  • node
  • npm
  • npx

These binaries run Node.js 20 regardless of the system default.

3. Add Aliases to .bashrc

To force your shell to use Node.js 20, add aliases to your .bashrc.

Edit .bashrc:

vim ~/.bashrc

Add the following lines:

You can add the following lines if not existing previously or update the node version path i.e alt-nodejs12 to alt-nodejs20

# User specific aliases and functions
alias npm="/opt/alt/alt-nodejs20/root/bin/npm"
alias node="/opt/alt/alt-nodejs20/root/bin/node"

Save and reload:

source ~/.bashrc

4. Verify the New Node Version

Run:

node -v

Expected output:

v20.x.x

You can also verify npm:

npm -v