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

After the installation is complete, run the following command:

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

That’s it! 😉

Andrew
Member since January 2, 2019

Comments

    Avatar

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

    Newsletter