What's?
wingetでパッケージをインストールすると、デフォルトでは最新バージョンがインストールされます。
ここで、各パッケージにはどのようなバージョンがあるのか、バージョンを指定してインストールする方法はあるのか調べてみました。
結論としては、--versions、--versionオプションを使います。
環境
今回の環境はこちらです。
PS > [System.Environment]::OSVersion
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.26200.0 Microsoft Windows NT 10.0.26200.0
PS > $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 26100 7462
PS > winget --version
v1.12.440
パッケージのバージョンを表示する
まずはパッケージにどのようなバージョンがあるのか表示してみます。
Node.jsをお題にしましょう。ひとつ前のLTSである22を使って試します。
winget search
パッケージを検索するsearchコマンド。
PS > winget search OpenJS.NodeJS.22
名前 ID バージョン ソース
----------------------------------------------
Node.js 22 OpenJS.NodeJS.22 22.22.0 winget
デフォルトだと最新版のバージョンが表示されますが、--versionsオプションを指定することでどのようなバージョンが使えるのかを表示できます。
PS > winget search --help
--versions パッケージの利用可能なバージョンを表示
確認。
PS > winget search OpenJS.NodeJS.22 --versions
見つかりました Node.js 22 [OpenJS.NodeJS.22]
バージョン
----------
22.22.0
22.21.1
22.21.0
22.20.0
22.19.0
22.18.0
22.17.1
22.17.0
22.16.0
22.15.1
22.15.0
22.14.0
22.13.1
22.13.0
22.12.0
22.11.0
22.10.0
22.9.0
22.8.0
22.7.0
22.6.0
22.5.1
22.5.0
22.4.1
22.4.0
22.3.0
22.2.0
22.1.0
22.0.0
ちなみに、パッケージが一意に特定できない場合はこのオプションは使えません。
PS > winget search OpenJS.NodeJS --versions
複数のパッケージが入力条件に一致しました。入力内容を修正してください。
名前 ID ソース
--------------------------------------
Node.js OpenJS.NodeJS winget
Node.js 10 OpenJS.NodeJS.10 winget
Node.js 12 OpenJS.NodeJS.12 winget
Node.js 14 OpenJS.NodeJS.14 winget
Node.js 15 OpenJS.NodeJS.15 winget
Node.js 16 OpenJS.NodeJS.16 winget
Node.js 17 OpenJS.NodeJS.17 winget
Node.js 18 OpenJS.NodeJS.18 winget
Node.js 19 OpenJS.NodeJS.19 winget
Node.js 20 OpenJS.NodeJS.20 winget
Node.js 21 OpenJS.NodeJS.21 winget
Node.js 22 OpenJS.NodeJS.22 winget
Node.js 23 OpenJS.NodeJS.23 winget
Node.js 4 OpenJS.NodeJS.4 winget
Node.js 6 OpenJS.NodeJS.6 winget
Node.js 7 OpenJS.NodeJS.7 winget
Node.js 8 OpenJS.NodeJS.8 winget
Node.js (LTS) OpenJS.NodeJS.LTS winget
winget show
パッケージの情報を表示するshowコマンド。
PS > winget show OpenJS.NodeJS.22
見つかりました Node.js 22 [OpenJS.NodeJS.22]
バージョン: 22.22.0
公開元: Node.js Foundation
発行元 URL: https://openjsf.org/
発行元のサポート URL: https://github.com/nodejs/node/blob/v22.22.0/.github/SUPPORT.md
作成者: OpenJS Foundation
モニカー: nodejs-22
説明: Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
ホーム ページ: https://nodejs.org/
ライセンス: MIT
ライセンス URL: https://github.com/nodejs/node/blob/v22.22.0/LICENSE
プライバシー URL: https://privacy-policy.openjsf.org/
著作権: Copyright Node.js contributors. All rights reserved.
著作権 URL: https://trademark-policy.openjsf.org/
リリース ノート:
This is a security release.
Notable Changes
lib:
- (CVE-2025-59465) add TLSSocket default error handler
- (CVE-2025-55132) disable futimes when permission model is enabled
lib,permission:
- (CVE-2025-55130) require full read and write to symlink APIs
src:
- (CVE-2025-59466) rethrow stack overflow exceptions in async_hooks
src,lib:
- (CVE-2025-55131) refactor unsafe buffer creation to remove zero-fill toggle
tls:
- (CVE-2026-21637) route callback exceptions through error handlers
Commits
- [6badf4e6f4] - deps: update c-ares to v1.34.6 (Node.js GitHub Bot) #60997
- [37509c3ff0] - deps: update undici to 6.23.0 (Matteo Collina) nodejs-private/node-private#791
- [eb8e41f8db] - (CVE-2025-59465) lib: add TLSSocket default error handler (RafaelGSS) nodejs-private/node-private#797
- [ebbf942a83] - (CVE-2025-55132) lib: disable futimes when permission model is enabled (RafaelGSS) nodejs-private/node-private#748
- [6b4849583a] - (CVE-2025-55130) lib,permission: require full read and write to symlink APIs (RafaelGSS) nodejs-private/node-private#760
- [ddadc31f09] - (CVE-2025-59466) src: rethrow stack overflow exceptions in async_hooks (Matteo Collina) nodejs-private/node-private#773
- [d4d9f3915f] - (CVE-2025-55131) src,lib: refactor unsafe buffer creation to remove zero-fill toggle (Сковорода Никита Андреевич) nodejs-private/node-private#759
- [25d6799df6] - (CVE-2026-21637) tls: route callback exceptions through error handlers (Matteo Collina) nodejs-private/node-private#796
リリース ノート URL: https://github.com/nodejs/node/releases/tag/v22.22.0
Documentation:
Learn: https://nodejs.org/learn/
Documentation: https://nodejs.org/docs/v22.22.0/api/
About: https://nodejs.org/about/
タグ:
coding
cross-platform
develop
development
environment
javascript
js
lts
node
npm
programming
runtime
v8
インストーラー:
インストーラーの種類: portable (zip)
インストーラーの URL: https://nodejs.org/dist/v22.22.0/node-v22.22.0-win-x64.zip
インストーラーの SHA256: c97fa376d2becdc8863fcd3ca2dd9a83a9f3468ee7ccf7a6d076ec66a645c77a
リリース日: 2026-01-12
オフライン配信をサポート: true
このコマンドには--versionオプションと--versionsオプションがあります。
PS > winget show --help
-v,--version 指定されたバージョンを使用します。既定値は最新バージョンです
--versions パッケージの利用可能なバージョンを表示
--versionオプションでは指定したバージョンの情報を表示します。
PS > winget show OpenJS.NodeJS.22 --version 22.10.0
見つかりました Node.js 22 [OpenJS.NodeJS.22]
バージョン: 22.10.0
公開元: Node.js Foundation
発行元 URL: https://openjsf.org/
発行元のサポート URL: https://github.com/nodejs/node/blob/v22.10.0/.github/SUPPORT.md
作成者: OpenJS Foundation
モニカー: nodejs-22
説明: Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
ホーム ページ: https://nodejs.org/
ライセンス: MIT
ライセンス URL: https://github.com/nodejs/node/blob/v22.10.0/LICENSE
プライバシー URL: https://privacy-policy.openjsf.org/
著作権: Copyright Node.js contributors. All rights reserved.
著作権 URL: https://trademark-policy.openjsf.org/
リリース ノート:
Notable Changes
New "module-sync" exports condition
This release introduces a "module-sync" exports condition that's enabled when require(esm) is enabled, so packages can supply a synchronous ES module to the Node.js module loader, no matter if it's being required or imported. This is similar to the "module" condition that bundlers have been using to support require(esm) in Node.js, and allows dual-package authors to opt into ESM-first only on newer versions of Node.js that supports require(esm) to avoid the dual-package hazard.
Or if the package is only meant to be run on Node.js and wants to fallback to CJS on older versions that don't have require(esm):
For package authors:
this only serves as a feature-detection mechanism for packages that wish to support both CJS and ESM users during the period when some active Node.js LTS versions support require(esm) while some older ones don't. When all active Node.js LTS lines support require(esm), packages can simplify their distributions by bumping the major version, dropping their CJS exports, and removing the module-sync exports condition (with only main or default targetting the ESM exports). If the package needs to support both bundlers and being run unbundled on Node.js during the transition period, use both module-sync and module and point them to the same ESM file. If the package already doesn't want to support older versions of Node.js that doesn't support require(esm), don't use this export condition.
For bundlers/tools:
they should avoid implementing this stop-gap condition. Most existing bundlers implement the de-facto bundler standard module exports condition, and that should be enough to support users who want to bundle ESM from CJS consumers. Users who want both bundlers and Node.js to recognize the ESM exports can use both module/module-sync conditions during the transition period, and can drop module-sync+module when they no longer need to support older versions of Node.js. If tools do want to support this condition, it's recommended to make the resolution rules in the graph pointed by this condition match the Node.js native ESM rules to avoid divergence.
We ended up implementing a condition with a different name instead of reusing "module", because existing code in the ecosystem using the "module" condition sometimes also expect the module resolution for these ESM files to work in CJS style, which is supported by bundlers, but the native Node.js loader has intentionally made ESM resolution different from CJS resolution (e.g. forbidding import './noext' or import './directory'), so it would be breaking to implement a "module" condition without implementing the forbidden ESM resolution rules. For now, this just implements a new condition as semver-minor so it can be backported to older LTS.
Contributed by Joyee Cheung in #54648.
node --run is now stable
This CLI flag runs a specified command from a package.json's "scripts" object.
You can run node --run test and that would start the test suite.
Contributed by Yagiz Nizipli in #53763.
Other notable changes
- [f0b441230a] - (SEMVER-MINOR) crypto: add KeyObject.prototype.toCryptoKey (Filip Skokan) #55262
- [349d2ed07b] - (SEMVER-MINOR) crypto: add Date fields for validTo and validFrom (Andrew Moon) #54159
- [bebc95ed58] - doc: add abmusse to collaborators (Abdirahim Musse) #55086
- [914db60159] - (SEMVER-MINOR) http2: expose nghttp2_option_set_stream_reset_rate_limit as an option (Maël Nison) #54875
- [f7c3b03759] - (SEMVER-MINOR) lib: propagate aborted state to dependent signals before firing events (jazelly) #54826
- [32261fc98a] - (SEMVER-MINOR) module: support loading entrypoint as url (RedYetiDev) #54933
- [06957ff355] - (SEMVER-MINOR) module: implement flushCompileCache() (Joyee Cheung) #54971
- [2dcf70c347] - (SEMVER-MINOR) module: throw when invalid argument is passed to enableCompileCache() (Joyee Cheung) #54971
- [f9b19d7c44] - (SEMVER-MINOR) module: write compile cache to temporary file and then rename it (Joyee Cheung) #54971
- [e95163b170] - (SEMVER-MINOR) process: add process.features.require_module (Joyee Cheung) #55241
- [4050f68e5d] - (SEMVER-MINOR) process: add process.features.typescript (Aviv Keller) #54295
- [86f7cb802d] - (SEMVER-MINOR) test_runner: support custom arguments in run() (Aviv Keller) #55126
- [b62f2f8259] - (SEMVER-MINOR) test_runner: add 'test:summary' event (Colin Ihrig) #54851
- [d7c708aec5] - (SEMVER-MINOR) test_runner: add support for coverage via run() (Chemi Atlow) #53937
- [5fda4a1498] - (SEMVER-MINOR) worker: add markAsUncloneable api (Jason Zhang) #55234
リリース ノート URL: https://github.com/nodejs/node/releases/tag/v22.10.0
Documentation:
Learn: https://nodejs.org/en/learn/
Documentation: https://nodejs.org/docs/v22.10.0/api/
About: https://nodejs.org/about/
タグ:
coding
cross-platform
develop
development
environment
javascript
js
node
npm
programming
runtime
v8
インストーラー:
インストーラーの種類: wix
インストーラーの URL: https://nodejs.org/dist/v22.10.0/node-v22.10.0-x64.msi
インストーラーの SHA256: 9d8fad0dc2da2c57e6fdf38fc85a23dc5ebcd5c414d8dd2948b3c45bd2398895
リリース日: 2024-10-16
オフライン配信をサポート: true
--versionsオプションの場合は、searchコマンドと同じ結果になります。
PS > winget show OpenJS.NodeJS.22 --versions
見つかりました Node.js 22 [OpenJS.NodeJS.22]
バージョン
----------
22.22.0
22.21.1
22.21.0
22.20.0
22.19.0
22.18.0
22.17.1
22.17.0
22.16.0
22.15.1
22.15.0
22.14.0
22.13.1
22.13.0
22.12.0
22.11.0
22.10.0
22.9.0
22.8.0
22.7.0
22.6.0
22.5.1
22.5.0
22.4.1
22.4.0
22.3.0
22.2.0
22.1.0
22.0.0
バージョンを指定してインストールする
パッケージをインストールするinstallコマンド。
デフォルトでは最新バージョンがインストールされます。
※PowerShellの新しいプロセスからパスに反映されます
PS > winget install OpenJS.NodeJS.22
PS > node --version
v22.22.0
このコマンドには--versionオプションがあり、こちらを使うと指定のバージョンでインストールできます。
PS > winget install --help
-v,--version 指定されたバージョンを使用します。既定値は最新バージョンです
とはいえ、複数のバージョンをインストールできるわけではないので先に別のバージョンが入っているとコンフリクトします。
PS > winget install OpenJS.NodeJS.22 --version 22.10.0
既存のパッケージが既にインストールされています。インストールされているパッケージ...をアップグレードしようとしています
利用可能なアップグレードが見つかりませんでした。
構成されたソースから入手できる新しいパッケージ バージョンはありません。
Version Managerのような使い方はできないということですね。
というわけで、1度アンインストール。
PS > winget uninstall OpenJS.NodeJS.22
今度はインストールできます。
PS > winget install OpenJS.NodeJS.22 --version 22.10.0
PS > node --version
v22.10.0
使うことがありそうなので、覚えておきましょう。