Upgrading npm on Windows requires manual steps to ensure that PowerShell/CMD find the new version of npm. This is a small tool made by Microsoft DX engineers with ❤️ for npm and Node, reducing the process to a simple command.
First, ensure that you can execute scripts on your system by running the following command from an elevated command prompt (either PowerShell or CMD.exe). To run PowerShell as Administrator, click Start, search for PowerShell, right-click PowerShell and select Run as Administrator
.
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
Then, to install and use this upgrader tool, run:
npm install -g npm-windows-upgrade
npm-windows-upgrade
The tool will show you a list of all the published and available versions of npm (including pre-release and beta versions). Choose the one you want to install and let it do its thing!
If you have trouble with the script, consider adding parameters manually. A common issue is that the script fails to find npm (and therefore doesn't know where to install it) - in that case, pass the location manually.
npm-windows-upgrade --npmPath:"C:\nodejs"
To manually specify a version to install, pass the version
parameter:
npm-windows-upgrade --version:3.1.0
Please do report your issues on GitHub. There are a bunch of Windows versions, hundreds of different ways to install Node and npm, and it's likely that this script won't work with a few of them. If you run into trouble and need npm upgraded as soon as possible, please follow the manual instructions.
This tool was made by Microsoft with ❤️ for npm and Node, but it is provided "as is", without warranty of any kind, expressed or
implied. For details, please consult the LICENSE
file.
Contributions are extremely welcome! For JavaScript code, please run grunt test
to check your code against JSCS and JSHint. There's no formal coding guideline for the PowerShell pieces of this tool, but do write code that is commented and comprehensible.