Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yarn - How do I update each dependency in package.json to the latest version?

I have a react app with deprecated dependencies. To make it work, I have to update the dependencies to their newer (but stable) versions.

As per this stakoverflow thread, to update dependencies in package.json to latest versions, npm-check-updates is the Best Option for npm. However, I'm using yarn for package management. Is there an equivalent of npm-check-updates in yarn. So that, I use a single package manager to manage my dependencies.

like image 730
DevLoverUmar Avatar asked Jun 30 '20 05:06

DevLoverUmar


People also ask

How do I update each dependency in package json to the latest version?

Simply change every dependency's version to * , then run npm update --save . (Note: broken in recent (3.11) versions of npm). Of course, this is the blunt hammer of updating dependencies.

How do you update all dependencies in yarn?

just run yarn upgrade-interactive --latest and select packages you want to update using space button and press the enter to update.

How do I change the dependencies in package json?

For updating a new and major version of the packages, you must install the npm-check-updates package globally. It will display the new dependencies in the current directory whereas running this command will list all the global packages which have new releases.


2 Answers

yarn upgrade-interactive --latest

But you have to have a yarn.lock file before do it. If you are using npm, you must delete package-lock.json first. Then run yarn to create structure. After that you can do upgrade-interactive. Without that, yarn shows upgrade, but no changes and effects in package.json.

like image 82
cybercoder Avatar answered Oct 10 '22 09:10

cybercoder


You can upgrade a single package to the latest major version with this:

yarn upgrade <package-name> --latest 
like image 35
Favour George Avatar answered Oct 10 '22 11:10

Favour George