How to Update node.js?

Better Stack Team
Updated on April 4, 2024

To update Node.js to the latest version, you can use a version manager like NVM (Node Version Manager) or download and install the latest version directly from the official Node.js website.

Using NVM (Node Version Manager)

If you have NVM installed, updating Node.js is straightforward:

  1. Open your terminal.
  2. Check the currently installed versions:

     
    nvm ls
    
  3. Install the latest Node.js version:

     
    nvm install node
    

    This command will install the latest stable version.

  4. Set the newly installed version as the default:

     
    nvm use node
    

    Alternatively, you can set it as the default version:

     
    nvm alias default node
    

Without NVM

If you don't use NVM, you can update Node.js by downloading and installing the latest version from the official website:

  1. Visit the Node.js Downloads page.
  2. Download the LTS (Long-Term Support) version or the latest version based on your preference.
  3. Run the installer and follow the installation instructions.

After updating, you can check the installed Node.js version to verify the update:

 
node -v

This will display the version number of the installed Node.js.

Keep in mind that if you are using any global Node.js packages, you might need to reinstall them after updating Node.js to ensure compatibility. Also, updating Node.js may require restarting your terminal or shell to apply the changes.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github