Upgrade all npm packages to the latest major version at once
Development

Upgrade all npm packages to the latest major version at once

Andrei Surdu Andrei Surdu ยท

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. ๐Ÿ™‚

Comments

Share your thoughts and join the conversation

Loading comments...

Leave a Comment

Your email will not be published

Comments are moderated and will appear after approval

0/2000