Reputation: 14011
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.
Upvotes: 216
Views: 309835
Reputation: 5868
yarn upgrade-interactive --latest
But you must have a valid yarn.lock
file before doing it. If you are using npm
, you must delete package-lock.json
at first. Then run yarn
(or yarn --ignore-engines
when there are version dependencies) to create structure. After that, you can do upgrade-interactive
. Without that, yarn
shows an upgrade, but no changes and effects in package.json
.
Upvotes: 330
Reputation: 2033
Update dependencies to latest versions, using jq:
jq '.dependencies | keys | .[]' package.json | xargs yarn add
Update dev dependencies to latest versions:
jq '.devDependencies | keys | .[]' package.json | xargs yarn add --dev
Upvotes: 6
Reputation: 2516
You can try this npm package yarn-upgrade-all
. This package will remove every package in package.json
and add it again which will update it to latest version.
installation:
npm install -g yarn-upgrade-all
usage: in your project directory run:
yarn-upgrade-all
Upvotes: 63
Reputation: 834
It can be done with --ignore-engines
flag. So package installation will not fail due to an incompatible node version.
First run:
yarn --ignore-engines
// This will install the older packages
And then:
yarn upgrade --ignore-engines
// This will update packages to latest
Upvotes: 0
Reputation: 442
If none of the answers worked for you, try to install again:
yarn add {PACKAGENAME HERE}
it will overwrite the current version to the latest version available
Upvotes: 2
Reputation: 33775
npm-check-updates is fully compatible with yarn. Just run npx npm-check-updates
in your project directory.
npm-check-updates
is a battle-tested, 8yr old library that just works. It offers interactive mode and doctor mode for automatically running tests and identifying broken upgrades.
Disclaimer: I am the main contributor of npm-check-updates.
Interactive + Group mode:
Upvotes: 16
Reputation: 600
yarn outdated
This will upgrade to the latest version, irrespective of if the package is stable or the versioning constraints between your packages.
yarn upgrade --latest
Upvotes: 14
Reputation: 20182
You have to install appropriate plugin first with:
yarn plugin import interactive-tools
and then execute
yarn upgrade-interactive
Source: https://yarnpkg.com/cli/upgrade-interactive
Upvotes: 30
Reputation: 1401
If you want to update packages with yarn and update the package.json accordingly,
yarn global add syncyarnlock
yarn upgrade
or yarn upgrade --latest
syncyarnlock -s
Upvotes: 7
Reputation: 653
In case you wanted to add the package to your package.json for development collaboration
yarn add yarn-upgrade-all -D
yarn yarn-upgrade-all
By the way, the package uses the command ( reinstall all packages again )
yarn install package1 package2 packageN
Upvotes: 4
Reputation: 1953
You can upgrade a single package to the latest major version with this:
yarn upgrade <package-name> --latest
Upvotes: 112
Reputation: 361
The one that worked for me is from a comment by @Andrew Zolotarev, which uses
npx yarn-upgrade-all
Upvotes: 24