The npm outdated
command is used to check the versions of installed packages and see if any package is currently outdated.
The command works by looking at the package.json
files located inside your node_modules
folder, the package.json
file that list your dependency versions, and the latest stable versions send by the npm registry.
You can call the command from the root directory of your project.
Here’s an example of the command output:
The command is immediately available once you installed npm, so you don’t need to install any package to use it.
To update your packages, you can modify the versions listed in your package.json
file to match the latest version shown in the output.
Once you updated the dependencies, save the changes and run npm install
.
Alternatively, you can also run npm install [package name]@latest
to update the packages:
npm install react@latest react-dom@latest # and so on...
When you have no outdated packages, then the command will not generate any output.
The outdated command can also be used to check globally installed packages:
npm outdated -g
In the output, the packages will be shown as dependencies of global:
To update these outdated global packages, add the -g
option to the npm install
command.
You also need to define the package versions as @latest
like when you update the local packages above:
npm install -g corepack@latest create-react-app@latest npm@latest
Now you’ve learned what npm outdated
does and how you can use it in your project. 👍