Skip to content Skip to sidebar Skip to footer

Should I Uninstall Nvm and Then Use Homebrew to Reinstall Again

How To Reinstall NPM and Node.js On Your System

The Node Bundle Director (usually shortened to npm) and Node.js are popular technologies among JavaScript developers. npm is the default package management utility that is installed automatically on your machine when you download and install Node.js.

npm assists in building, consuming, managing, and sharing modest pieces of code. On the other paw, Node.js provides a server-side environment for creating powerful applications.

Yet, at times, npm can become corrupted, become incompatible with other programs, or just experience performance issues. In such cases, information technology may help to reinstall npm on your system and save yourself the hassles. Similarly, reinstalling Node.js may assist yous in clearing out any performance errors.

And since npm is shipped with Node.js by default, installing Node.js will also install npm on your system.

In this article, you're going to learn how to reinstall npm and Node.js on dissimilar operating systems—Windows, macOS, and Linux.

These are the topics we'll talk about:

  • How to check if reinstallation succeeded
  • How to reinstall npm and Node.js on Windows
  • How to reinstall npm and Node.js on macOS
  • How to reinstall npm and Node.js on Linux
  • Conclusion

How to check if reinstallation succeeded

Note that later completing the reinstallation process, you can check if it was successful past running the following commands on the terminal:

So, if everything went well, the system volition output your installed versions.

Something like this:

Since npm is normally updated more than frequently than Node.js, your installation may not come with the latest npm version.

So, if your installed npm version is not the latest, you can update it by running the following command:

The above command will install the latest, stable npm version. Yet, if you want to experiment with things past using a version that will exist released in the future, you tin run the following:

If you desire to update Node.js to the latest version, you tin read this article.

How to reinstall npm and Node.js on Windows

If the npm or Node.js running on your Windows environs is broken, yous can reinstall and get the well-nigh out of them.

Y'all can use whatever of the post-obit methods:

  • Reinstalling using a Node version manager
  • Reinstalling using a Node installer

Allow's talk about each of them.

a) Reinstalling using a Node version manager

A Node version manager is a tool you can use to install various versions of Node.js and npm and shift between them seamlessly.

A popular Node version management tool you can apply is nvm-windows . It's a powerful command line utility that allows you to manage multiple installations of Node.js comfortably.

Before installing the utility, it is recommended to remove all the existing versions of Node.js and npm from your Windows computer. This volition prevent whatever conflict issues when installing the software.

You can uninstall them by doing the following:

  • Go to the Windows Command Panel and uninstall the Node.js plan.
  • If whatsoever Node.js installation directories are still remaining, delete them. An example is C:\Program Files\mynodejs.
  • If whatever npm install location is all the same remaining, delete it. An example is C:\Users\<username>\AppData\Roaming\npm.

Then, once your system is clean, become to this page and download and run the latest nvm-windows installer. After it has been installed, you tin first the Control Prompt or Powershell as an Administrator and use the tool to reinstall Node.js and npm.

If you lot desire to reinstall a specific Node.js version, you can run the following command:

Let'southward say you lot desire to reinstall Node.js version 12.18.0, you lot can run:

If you want to reinstall the latest stable Node.js version, you can run:

If you want to cheque the listing of Node.js versions available for download, you can run:

To use the installed Node.js version in your projection, y'all tin switch to information technology:

b) Reinstalling using a Node installer

Using the official Node installer is the easiest way to reinstall Node.js and npm on your Windows environment.

To use this choice, you can go to the Node.js download page and reinstall the latest Node.js version.

It is recommended to download the version labeled LTS (Long-term Supported) because it has been tested with npm. Although the version labeled Current comes with the latest features, it may be unstable and unreliable.

After selecting the version you want to download, and clicking the Windows Installer choice, the installation wizard will magically complete the installation process for you.

Ultimately, the installer will automatically overwrite your existing, malfunctioned Node.js version with a new one.

How to reinstall npm and Node.js on macOS

Before reinstalling Node.js and npm on your macOS system, y'all'll need to remove any previously installed versions.

Hither are some ways you can use to uninstall them:

  • Manually —this involves manually removing whatever references of Node and npm from your system. Unfortunately, this process is difficult since there may be several directories with Node resources. For case, you may demand to delete the node executable and node_modules from / usr/local/lib , delete .npm from the home directory, and delete many other directories.
  • Using a script —this involves running a script to uninstall Node.js and npm automatically from your macOS organisation. You can find a elementary script to use here .
  • Using Homebrew—this parcel direction utility lets you lot complete the uninstallation process fast and hands. You tin run the following command:

And then, once your system is clean, you tin use whatever of the following methods to reinstall Node.js and npm on macOS:

  • Reinstalling using a Node installer
  • Reinstalling using Homebrew
  • Reinstalling using a Node version manager

Let'south talk nigh each of them.

a) Reinstalling using a Node installer

To employ the official Node installer for reinstalling the tools, go to the Node.js download page and select the version you desire to install—just equally nosotros described previously.

Remember to cull the macOS installer option. If you run the installer, it will consummate the reinstallation process for you automatically.

b) Reinstalling using Homebrew

To reinstall using Homebrew, just run the following control on the macOS terminal:

c) Reinstalling using a Node version manager

You can besides reinstall the two tools using the nvm Node version manager. Since the procedure for using nvm is the same for both macOS and Linux, we'll describe how to utilize it in the side by side section.

How to reinstall npm and Node.js on Linux

Just like in the previous cases, you'll demand to remove any installed version of Node.js and npm before reinstalling them on a Linux distribution, such as Ubuntu.

Here are some means you lot tin use to uninstall them:

  • Using the apt bundle managing director —you lot tin can remove Node.js past running the following command:

The above control will delete the distro-stable version while retaining the configuration files for later use. Nonetheless, if yous intend to remove the parcel as well equally its configuration files, run the following:

Finally, you can delete any unused packages that were installed automatically with the deleted package:

  • Using nvm —yous tin can as well use the nvm Node version director to uninstall Node.js from your organisation. We'll illustrate how to do this in the adjacent department.

And then, once your machine is clean, you can use whatever of the following methods to reinstall Node.js and npm on Linux:

  • Reinstalling using a Node version manager
  • Reinstalling using the apt package manager

Let'southward talk about each of them.

a) Reinstalling using a Node version director

As earlier mentioned, you can use the nvm Node version manager to reinstall Node.js and npm on both macOS and Linux.

To install the script-based tool, you tin can use either Wget or cURL.

If using Wget, execute the following on the concluding:

If using cURL, execute this:

The above commands will install nvm version 0.35.0 on your system. Recall to check the latest version and refer to it accordingly on the command yous want to run.

To verify if information technology was installed successfully, run the following:

If all went well, it would output nvm .

Later on installing nvm , yous can utilize information technology to reinstall Node.js on your system.

Simply, execute the following control:

To reinstall a specific Node.js version, run:

For example, to reinstall Node.js version 12.18.0, execute:

One time reinstallation is complete, you can set that Node.js version for utilize as the system-wide default version:

Furthermore, you can cheque the list of Node.js versions available for download by executing the following:

To remove a Node.js version that you've set using nvm , start by establishing if the version is currently active on your organization:

If it is not actively running, execute the following to uninstall it:

On the other hand, if the version targeted for removal is the current active version, you'll need to deactivate nvm first:

Then, you can use the to a higher place uninstall command to remove it from your system.

b) Reinstalling using the apt package manager

A simpler way to reinstall Node.js and npm on a Linux distribution, such every bit Ubuntu, is to use the apt bundle manager.

To practise so, y'all can start by refreshing your local bundle index:

Then, reinstall the distro-stable Node.js version from the repositories:

In most cases, this is all you need to get up and running with Node.js. Also, you may want to reinstall npm by running the following command:

Determination

That's how to reinstall npm and Node.js on Windows, macOS, and Linux.

After completing the reinstallation, you'll avoid any performance issues that oft arise from using malfunctioned versions of the technologies.

Practice y'all take whatsoever comments or questions?

Please post them below.

Happy coding!


Are you letting open up-source vulnerabilities go undetected?

WhiteSource Bolt is a powerful free extension that operates in real-time to provide visibility over your open source components inside Azure Pipelines or GitHub.

  • Get existent-time alerts on security vulnerabilities
  • Ensure the license compliance of open source components.
  • Receive automated open-source inventory reports for every build or project.

Get it at present and join thousands of developers who've already gained full visibility over their open up-source components.

mooreeptich.blogspot.com

Source: https://www.whitesourcesoftware.com/free-developer-tools/blog/reinstall-npm-node-js/

Postar um comentário for "Should I Uninstall Nvm and Then Use Homebrew to Reinstall Again"