node.jsnpm

How can I install Node.js version 18 on Ubuntu 22.04?


How to install node js version 18 on ubuntu 22.04 ?

cd ~
curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs

I tried these commands many times, but always version v12.22.9 is installed.

To build an app with React, I need Node 14 or higher.

What do you recommend ?


Solution

  • I recommend using Node Version Manager:

    NB: Node Version Manager (nvm) allows you to install multiple node versions and choose between them depending on which software you want to support; that is, manage multiple node versions.

    Installing Node Version Manager

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

    Once you have Node Version Manager installed

    1. Confirm the available remote versions by running nvm ls-remote
    2. Run in your terminal nvm install <version> for example, nvm install 18 to install version 18 of Node
    3. List installed versions with nvm list
    4. Run nvm use 18 to start using version 18 of Node
    5. Note: you can be more explicit, for example: nvm install 14.17.0