Skip to content

Instantly share code, notes, and snippets.

@nmalkin
Last active December 24, 2019 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmalkin/192bedd1859ae32beb58f2625cb2dbda to your computer and use it in GitHub Desktop.
Save nmalkin/192bedd1859ae32beb58f2625cb2dbda to your computer and use it in GitHub Desktop.
npm install latest available package (equivalent of `yarn upgrade --latest`)

npm install latest available package (equivalent of yarn upgrade --latest)

npm outdated --parseable --depth=0 | cut -d: -f4 | xargs npm install

Background

Per the official documentation, here's what yarn upgrade --latest does:

The upgrade --latest command upgrades packages the same as the upgrade command, but ignores the version range specified in package.json. Instead, the version specified by the latest tag will be used (potentially upgrading the packages across major versions).

As best I can tell, there is no equivalent command for npm, though people have asked for it and have even created npm packages that do this.

Based on another gist, this is a one-liner that achieves similar behavior.

Warning: this will overwrite your currently installed packages, and — as always when chaining multiple commands — things can go wrong. Please understand what you're doing, and don't run this command if you're worried about your environment or package.json getting messed up.

npm outdated --parseable --depth=0 | cut -d: -f4 | xargs npm install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment