Update all node dependencies to their latest version without updating one by one

Parathan Thiyagalingam
2 min readJan 1, 2022
Photo by Andrew Neel on Unsplash

This process will sometimes trouble you at some point. Because software maintenance & upgrade will cost a lot; unless we are aware of what we are doing.

In this post, I wanted to bookmark myself the process of updating all node dependencies in the package.json file to their latest version without updating each dependency one by one.

npm outdated

The above command will give the outdated dependencies and their available latest versions. To update one by one we need to execute the following command

npm install <package_name>@latest 

But, if you know that you can able to handle the version issue by upgrading all the dependencies to the latest version then follow the below instructions.

To update to a new major version of all the packages, install the npm-check-updates package globally:

npm install -g npm-check-updates

then run it:

ncu -u

After running the above command, you will see in the package.json devDependencies & dependencies are updated with the latest version. Now, run the below command to update the versions in the node_modules folder.

npm update

If you don’t have node_modules created in the project? then run the following command to install node_modules of the project.

npm install

Happy coding…!!

--

--