Use npm outdate
and npm update
to check for and update to newer versions of your installed node modules using npm's built-in commands.
npm outdated
Current
is what you have installedWanted
is the latest version that satisfies the semver range in package.jsonLatest
is, you guessed it, the latest.
Red items mean the wanted version is also the latest.
npm update
This will update all packages to the wanted
version.
My package.json has "react": "^16.13.1"
listed as a dependency. npm update
would change this to "react": "^16.14.0",
, not v17.
Running npm outdated
again would show I have every package updated the wanted version.
Individual packages can be updated by listing the package names in the command e.g. npm update react react-dom
Updating to the latest and greatest
npm update
only gets you as far as your semver range. If you want to break above that and get the latest, append @latest
to the package name. e.g. npm install react@latest
Update Globally Installed Packages
All three commands work globally with the addition of -g
or --global
npm outdated -g
npm update -g
npm install -g package@latest