How To Update Node Windows
Node is a runtime environment that allows developers to execute JavaScript code outside the browser, on the server-side.
NPM, on the other hand, is a package director for publishing JavaScript packages (besides known as Node modules) to the npm registry. You lot tin can also apply it to install packages to your applications.
To install Node, you have to go to the Nodejs website to download the installer. After downloading, you tin can run the installer, follow the steps, agree to the terms and weather, and have the installer on your device.
When you install Node, y'all also get the npm
CLI which you tin can use to manage packages in your applications.
However, Node and NPM tin can be updated separately to their latest versions, and in the rest of this article, I'll show you how.
How to Update Node
1. Use NPM to Update Your Node Version
To update Node with NPM, you will install the n package, which volition be used to interactively manage node versions on your device.
Hither are the steps:
Clear the NPM cache
When yous install dependencies, some modules are cached to improve the speed of installation in subsequent downloads. Then showtime, yous want to clear the NPM cache.
Install north
npm install -k n
You lot'll need to install this parcel globally equally information technology manages the Node versions at the root.
Install a new version of Node
n lts n latest
The ii commands to a higher place install the long-term support and latest versions of Node.
Remove previously installed versions
n clip
This command removes the cached versions of the previously installed versions and only keeps the latest installed version.
2. Employ NVM to Update Your Node Version
NVM stands for Node Version Managing director, and as the name implies, it helps you manage your Node Versions. With NVM, yous can install Node versions and specify the version of Node that a projection uses.
NVM makes information technology piece of cake to test projects beyond various Node versions.
To update a Node Version with NVM, you accept to install NVM first.
Hither is the installation guide for NVM.
When installed, you can install packages with:
nvm install [version]
Yous tin install the latest version with:
nvm install node
And uninstall other versions with:
nvm uninstall [version]
With many versions installed, you may also want to specify the version to use at a particular time. One way to do this is by setting a default alias like this:
nvm allonym default [version]
This way, Node executions will run with the specified version.
3. Download Updated Node Binaries
And you tin can as well become the latest versions from the Node.js website. On it, y'all tin detect the latest and long-term support versions for your device.
Downloading the latest version too gives you the latest version of NPM.
How to Update NPM
Just as y'all use NPM to update packages, you tin can use NPM to update itself. Here'south the command to achieve this:
npm install -g npm@latest
This control will install the latest version of NPM globally.
On Mac, you may take to pass the sudo
control earlier NPM, equally this installs NPM at the root of your device, and you need privileges to practise that.
Conclusion
In this article, we've seen how to update Node and NPM to their latest versions.
To reiterate, when you install Node, you automatically get NPM. If yous too update Node by installing the binaries from the website, you get an updated NPM.
We also saw other ways to update Node and NPM globally on your device.
Learn to code for free. freeCodeCamp's open source curriculum has helped more than than twoscore,000 people become jobs every bit developers. Go started
Source: https://www.freecodecamp.org/news/how-to-update-node-and-npm-to-the-latest-version/
Posted by: smithsursee.blogspot.com
0 Response to "How To Update Node Windows"
Post a Comment