It’s essential to keep all the node modules of your project up to date as the security patches go out.
In this short tutorial I’ll teach you how to update all the
node_modules to the latest version with a single command.
By default, once you type
npm install <package_name>, node package manager installs the latest version of
the desired package. This version is then added automatically to the file
The issue is that over time new versions of the packages are being released, and you need to somehow update them.
To check which packages are outdated, you can run the command
npm outdated, however
Node Package Manager (npm), doesn’t update dependencies from
package.json by default.
So, if you’re looking to update all the npm modules with a single command, you can use the module
It’s best to install this module globally with the
npm install -g npm-check-updates
After successful installation, you’ll be able to use the command
ncu from the command line.
Make sure that you navigate to your project directory before using the
ncu -u command. Once you execute it,
npm-check-updates will update all the dependencies from
package.json to the fresh versions.
The last step is to run the command
npm install to download and install updated packages based on the information