Npm Install Reinstalls All Packages Again
How To Reinstall NPM and Node.js On Your System
The Node Package Manager (usually shortened to npm) and Node.js are pop technologies amid JavaScript developers. npm is the default package management utility that is installed automatically on your car when you download and install Node.js.
npm assists in building, consuming, managing, and sharing minor pieces of code. On the other hand, Node.js provides a server-side environment for creating powerful applications.
However, at times, npm can become corrupted, get incompatible with other programs, or only experience operation issues. In such cases, information technology may help to reinstall npm on your system and salve yourself the hassles. Similarly, reinstalling Node.js may aid y'all in clearing out any performance errors.
And since npm is shipped with Node.js by default, installing Node.js will too install npm on your arrangement.
In this article, you're going to acquire how to reinstall npm and Node.js on different operating systems—Windows, macOS, and Linux.
These are the topics nosotros'll talk nearly:
- How to bank 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
- Decision
How to check if reinstallation succeeded
Note that subsequently completing the reinstallation process, you can check if it was successful by running the following commands on the concluding:
And then, if everything went well, the system will output your installed versions.
Something like this:
Since npm is usually updated more 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 information technology past running the following control:
The above command volition install the latest, stable npm version. Still, if y'all want to experiment with things by using a version that will be released in the future, yous can run the following:
If y'all desire to update Node.js to the latest version, y'all can read this commodity.
How to reinstall npm and Node.js on Windows
If the npm or Node.js running on your Windows environment is broken, you can reinstall and get the virtually out of them.
You can utilize any of the post-obit methods:
- Reinstalling using a Node version director
- Reinstalling using a Node installer
Let'due south talk most each of them.
a) Reinstalling using a Node version managing director
A Node version manager is a tool you can employ to install various versions of Node.js and npm and shift betwixt them seamlessly.
A popular Node version direction tool you can employ is nvm-windows . It'south a powerful command line utility that allows you lot 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 will prevent any conflict issues when installing the software.
You can uninstall them past doing the following:
- Get to the Windows Control Panel and uninstall the Node.js programme.
- If any Node.js installation directories are all the same remaining, delete them. An example is C:\Program Files\mynodejs.
- If any npm install location is still remaining, delete it. An example is C:\Users\<username>\AppData\Roaming\npm.
Then, in one case your arrangement is clean, get to this page and download and run the latest nvm-windows installer. Later on it has been installed, you can start the Command Prompt or Powershell as an Administrator and use the tool to reinstall Node.js and npm.
If yous want to reinstall a specific Node.js version, you can run the following command:
Let'southward say you want to reinstall Node.js version 12.18.0, yous can run:
If you want to reinstall the latest stable Node.js version, y'all can run:
If you want to check the listing of Node.js versions available for download, you can run:
To utilise the installed Node.js version in your project, you lot can switch to it:
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 selection, you tin can get 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 information technology 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 selection, the installation magician volition 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, you'll need to remove whatsoever previously installed versions.
Hither are some means yous can use to uninstall them:
- Manually —this involves manually removing any references of Node and npm from your system. Unfortunately, this process is hard since there may be several directories with Node resources. For instance, 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 system. You lot can find a simple script to use here .
- Using Homebrew—this package direction utility lets you consummate the uninstallation process fast and hands. Y'all can run the following command:
And then, in one case your system is make clean, you tin utilise whatsoever 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'southward talk about each of them.
a) Reinstalling using a Node installer
To utilise the official Node installer for reinstalling the tools, go to the Node.js download page and select the version y'all want to install—just every bit we described previously.
Remember to choose 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 command on the macOS last:
c) Reinstalling using a Node version manager
You can as well reinstall the two tools using the nvm Node version manager. Since the process for using nvm is the same for both macOS and Linux, we'll draw how to use it in the next department.
How to reinstall npm and Node.js on Linux
Just like in the previous cases, you'll need to remove any installed version of Node.js and npm earlier reinstalling them on a Linux distribution, such as Ubuntu.
Here are some ways you can use to uninstall them:
- Using the apt parcel manager —you tin can remove Node.js by running the post-obit command:
The in a higher place command will delete the distro-stable version while retaining the configuration files for later use. However, if you intend to remove the parcel every bit well as its configuration files, run the following:
Finally, you lot can delete any unused packages that were installed automatically with the deleted packet:
- Using nvm —yous can also use the nvm Node version manager to uninstall Node.js from your system. We'll illustrate how to exercise this in the next section.
Then, once your machine is make clean, you tin can use whatsoever of the following methods to reinstall Node.js and npm on Linux:
- Reinstalling using a Node version manager
- Reinstalling using the apt packet managing director
Let'southward talk nearly each of them.
a) Reinstalling using a Node version manager
As earlier mentioned, you tin use the nvm Node version manager to reinstall Node.js and npm on both macOS and Linux.
To install the script-based tool, you lot can use either Wget or coil.
If using Wget, execute the following on the final:
If using curl, execute this:
The above commands will install nvm version 0.35.0 on your system. Remember to bank check the latest version and refer to it accordingly on the command you want to run.
To verify if it was installed successfully, run the following:
If all went well, it would output nvm .
After installing nvm , you tin can use it to reinstall Node.js on your system.
Simply, execute the following command:
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 up that Node.js version for use every bit the organisation-broad default version:
Furthermore, you lot can cheque the list of Node.js versions available for download by executing the post-obit:
To remove a Node.js version that you've fix using nvm , outset past establishing if the version is currently active on your system:
If it is not actively running, execute the post-obit to uninstall it:
On the other paw, if the version targeted for removal is the current active version, you'll demand to deactivate nvm first:
Then, you can use the above uninstall command to remove it from your organization.
b) Reinstalling using the apt bundle manager
A simpler way to reinstall Node.js and npm on a Linux distribution, such as Ubuntu, is to utilize the apt package manager.
To do then, you can start past refreshing your local parcel index:
And so, reinstall the distro-stable Node.js version from the repositories:
In well-nigh cases, this is all yous need to get up and running with Node.js. Also, y'all may want to reinstall npm by running the post-obit command:
Conclusion
That's how to reinstall npm and Node.js on Windows, macOS, and Linux.
After completing the reinstallation, y'all'll avoid any performance problems that often arise from using malfunctioned versions of the technologies.
Do you lot have any comments or questions?
Please mail service them below.
Happy coding!
Are yous letting open-source vulnerabilities go undetected?
WhiteSource Bolt is a powerful free extension that operates in existent-time to provide visibility over your open source components within Azure Pipelines or GitHub.
- Get real-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 total visibility over their open-source components.
Source: https://www.whitesourcesoftware.com/free-developer-tools/blog/reinstall-npm-node-js/
0 Response to "Npm Install Reinstalls All Packages Again"
Post a Comment