Upgrade all npm packages to the latest major version at once

While this may look like a dangerous idea, it is actually something that many of us wanted to do just to get rid of those warnings when we run npm install.

In the latest project, I upgraded my webpack config, and to my surprise, I could run the project and got zero errors.

Of course, I was lucky, and you may end up with some errors/warnings that you may need to fix yourself, but in the end you will use the latest versions of each package that is required. 🙂 Doing so you’ll get fewer worries about security so much anymore.

You can run the following command to see all outdated packages:

npm outdated

This one will give you a good image of what you should do.

Next, install a global package:

npm install -g npm-check-updates

You can learn more about this package on npm registry page.

After the installation is complete, run the following command to check if upgrades are available:

ncu

If you think that you are ready to upgrade, add -u argument. Be carefull, this will upgrade evertything and your code may not work anymore. Additional work may be required.

ncu -u

This will update the numbers from package.json, but not the packages code. To do so, run npm install and you are done:

npm i

Now to hardest part is to test the code with the new packages. 🙂

Member since January 2, 2019

As a seasoned WordPress developer with expertise in various tech stacks and languages, I bring years of experience to every project I handle. My passion for coding and dedication to delivering exceptional work ensures that each project I take on is of the highest quality. I specialize in creating custom themes, developing plugins, and building full-scale web systems. By staying up-to-date with the latest industry trends and best practices, I incorporate cutting-edge solutions into my work.

Comments

    Your email address will not be published. Required fields are marked *