0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

package.json の依存関係を更新する方法

Last updated at Posted at 2023-03-02

npmのバージョニング

npm は semantic versioning を採用しています。

1.          2.            3
↑メジャー  ↑マイナー   ↑パッチ
  • メジャーは、互換性のない API の変更に関するもの
  • マイナーは、下位互換性のある機能用
  • パッチは、下位互換性のあるバグ修正用

^(キャレット)と~(チルダ)の意味

  • キャレット(マイナー)
    • ^1.2.3 = 1.x
    • 1.2.3 <= version < 2.0.0
  • チルダ(パッチ)
    • ~1.2.3 = 1.2.x
    • 1.1.2 <= version < 1.2.0

依存関係の更新

# 依存関係に更新情報があるのか確認する
npm outdated
# package.jsonを修正したら依存関係を更新する
npm update
# インストールされているバージョンを確認する
npm ls

メジャーバージョンをアップグレードする場合

# ncuのインストール
npm install -g npm-check-updates
# 更新内容を確認
ncu
# 更新(メジャーバージョンを含む)
ncu -u

メジャーバージョンをアップグレードするときは十分注意をしてください

Visual Studio Code に Version Lens をインストールしている場合は、すべてのパッケージの最新バージョンが表示されます。

参考

https://betterprogramming.pub/how-to-upgrade-dependencies-in-package-json-e5546804187f
https://docs.npmjs.com/cli/v8/configuring-npm/package-json
https://github.com/npm/node-semver#versions

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?