<p>Note: The question is specifically asking how to upgrade npm, not Node.js. If you want to update Node.js over a CLI on windows, I recommend running <code>winget upgrade -q NodeJS</code> or use <a href="https://community.chocolatey.org/packages/nodejs-lts">chocolatey</a> for that.</p>
<p>What method should I choose to update NPM?</p>
<ul>
<li>
<p>Node.js v16 or higher?</p>
</li>
<li>
<p><code>npm install -g npm</code></p>
</li>
<li>
<p>Node.js v14 or below?</p>
</li>
<li>
<p>Consider updating to latest LTS release of Node.js</p>
</li>
<li>
<p><code>npm-windows-upgrade</code></p>
</li>
</ul>
<p><a href="https://github.com/felixrieseberg/npm-windows-upgrade">Upgrade with npm-windows-upgrade</a></p>
<p>Run PowerShell en tant qu’administrateur</p>
<pre><code class="lang-auto">Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
</code></pre>
<p>Note: if you run the Node.js installer, it will replace the Node.js version.</p>
<ul>
<li>
<p>Upgrades npm in-place, where Node.js installed it.</p>
</li>
<li>
<p>Does not modify the default path.</p>
</li>
<li>
<p>Does not change the default global package location.</p>
</li>
<li>
<p>Allows easy upgrades and downgrades and to install a specific version.</p>
</li>
<li>
<p>A list of versions matched between NPM and Node.js (<a href="https://nodejs.org/en/download/releases/">https://nodejs.org/en/download/releases/</a>) - but you will need to download the <em>Node.js installer</em> and run that to update Node.js (<a href="https://nodejs.org/en/">https://nodejs.org/en/</a>)</p>
</li>
</ul>
<p>Upgrade with npm</p>
<pre><code class="lang-auto">npm install -g npm
</code></pre>
<p>Note: some users still report issues updating npm with npm, but I haven’t had that experience with v16+.</p>