Upgrading Node.js using NVM (Node Version Manager) is straightforward. Here’s how you can do it step by step:
1. Check the current Node.js version: Run this command to check the version of Node.js currently in use:
node -v
2. List available Node.js versions: To see the latest available Node.js versions, use:
nvm ls-remote
This command will display a list of all available Node.js versions. Look for the latest LTS (Long-Term Support) version or the latest stable version.
3. Install the desired Node.js version: Choose the version you want to upgrade to and install it. For example, to install the latest LTS version:
nvm install --lts
Alternatively, to install a specific version (e.g., 18.16.0):
nvm install 18.16.0
4. Set the default Node.js version: After installing, set the newly installed version as the default version for your shell:
nvm alias default
For example:
nvm alias default 18.16.0
5. Verify the new Node.js version: Check that the upgrade was successful:
node -v
6. Uninstall old versions (optional): If you want to free up space, you can remove older versions of Node.js that you no longer need:
nvm uninstall
For example:
nvm uninstall 16.20.0
If you ever need to use a different version of Node.js, you can switch versions easily:
nvm use
For example:
nvm use 16.20.0
nvm --version
Update NVM if necessary by following its installation instructions in the NVM GitHub repository.
This process ensures you are using the right version of Node.js for your development environment without affecting global configurations.
Work with our skilled Node developers to accelerate your project and boost its performance.
Hire Node.js Developers