How to update all global npm packages
By Flavio Copes
Update all global npm packages with npm update -g, check outdated tools, update one package, and understand which Node installation you are changing.
To update all globally installed npm packages, run:
npm update -g
The -g flag means global. It targets the command-line tools you installed with npm install -g, such as Wrangler or TypeScript.
You can run this command from any directory. It updates the packages in your active npm global installation. Your project’s dependencies have their own update workflow.
Check which packages need updating
Before updating, you can see which global packages have newer versions available:
npm outdated -g
The output includes each package’s installed version and its available versions. If nothing is outdated, the command prints nothing.
You can also list your global packages, including ones that are already up to date:
npm list -g --depth=0
The --depth=0 option keeps the list focused on packages you installed directly.
Update everything, or just one tool
Run npm update -g to update all global packages. Then run npm outdated -g again to check what remains.
To update a single tool, add its package name. For example, to update a globally installed Wrangler:
npm update -g wrangler
For global packages, npm normally targets the release tagged latest. That can include a major version change, so read the release notes for tools you rely on before updating everything. If you installed a prerelease newer than latest, updating can move it back to that release. The npm update documentation explains this behavior.
Which global installation gets updated?
If you switch Node.js versions with a version manager, you can have different sets of global packages.
Check the global prefix used by your current npm command:
npm prefix -g
The update applies to that installation. After switching Node versions, check its global packages again if a tool appears to be missing or outdated.
For more on how npm stores packages, see global versus local npm packages. My free Node.js course covers packages and modules alongside the rest of the runtime.
Want me to talk about your product? You can sponsor this site.
Related posts about node: