LoginSignup
23
8

More than 5 years have passed since last update.

yarn upgrade-interactive と同じように npm でも対話型な更新をしたい!

Last updated at Posted at 2018-12-05

前書き

ところで皆さん、パッケージマネージャーは yarn と npm どちらを利用していますか?

yarn のリリース直後、「高速なダウンロード!lock ファイル (yarn.lock) による依存ライブラリのバージョン固定!最&高!」と感動し、 npm から yarn に切り替えたのを覚えています。

しかし、npm v5 のリリースにより、速度が改善され、更には lock ファイル (package-lock.json) が生まれました。
この時から、「あれ、yarn って必要?」と思うようになりました。

npm に切り替えたいですが、 yarn には upgrade-interactive コマンドという大変便利な、対話型な更新が可能なコマンドを標準で備えています。
yarn upgrade-interactive について知りたい方は、こちらを参照するのが良いです。

「npm でも対話型な更新をしたいんや!」

npm で対話型な更新をする

先ずは npm-check をインストールし、

$ npm install npm-check --save-dev

package.json の npm-scripts を以下のように修正します。

package.json
{
    "scripts": {
        "upgrade-interactive": "npm-check --update"
    }
}

後は、以下のように実行するだけです。

$ npm run upgrade-interactive

すると、yarn upgrade-interactive と同じように対話型な更新が可能です。

npm-check -u
引用元: https://github.com/dylang/npm-check

さっき知ったのですが、yarn upgrade-interactive の公式ドキュメントに、

npm-check の対話型の更新モードと同様です。

と記載されていました。

23
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
8