skip to Main Content

I am trying to update node on UBUNTU (version 22.04.4 LTS) and have followed the official procedure on their site:

# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# download and install Node.js (you may need to restart the terminal)
nvm install 21
# verifies the right Node.js version is in the environment
node -v # should print `v21.7.3`
# verifies the right NPM version is in the environment
npm -v # should print `10.5.0`

At first everything seemed OK, giving me the exact versions of both node and npm. But after closing and reopening the terminal it gives me the version of node: v23.0.0-nightly2024071586415e4688 and as npm version says:

npm warn cli npm v10.8.2 does not support Node.js v23.0.0-nightly2024071586415e4688. This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.
10.8.2

How can such a thing happen if I have copied and pasted exactly the commands the official website says to use???
How can I solve it? I’ve tried deleting and repeating the same procedure but I get the same result as above, I’ve tried restarting the pc and repeating with a newer version but nothing, and I’ve tried the same with an older version…I always get the same problem!

2

Answers


  1. Chosen as BEST ANSWER

    I finally solved it with nvm alias default 21.7.3 and then with nvm use 21.7.3.

    It seems to work


  2. Step 1: Install nvm

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

    Step 2: Load nvm into the current shell session

    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
    [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
    

    Step 3: Install Node.js version 21

    nvm install 21
    

    Step 4: Verify the installation

    node -v  // Should print the installed Node.js version, e.g., v21.7.3
    npm -v   // Should print the installed npm version, e.g., 10.5.0
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search