node --version

パッケージと実行環境

書き方

node --version | node -v

PATHの先頭で見つかるnodeのバージョンを表示します。バージョン管理ツールがシェルごとに別のものを指すため、エディターの端末やCIが違う版を使うことがよくあります。

よく使うオプション

オプション意味
-vthe same thing, shorter; prints e.g. v22.14.0
-p <expr>print one expression, e.g. node -p process.versions.v8
-e <code>run a line of code with no file
--env-file=<file>load a .env before running, from node 20.6
--helpevery flag this build accepts

node --version

the version of the node first on your PATH

node -p process.execPath

which binary that actually is, when several are installed

node -p process.versions.v8

the V8 version bundled with it

何をどこに入れるかが問題です。このプロジェクトの中か、マシン全体かを先に決めてください。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. node --version は何をしますか。

PATHの先頭で見つかるnodeのバージョンを表示します。バージョン管理ツールがシェルごとに別のものを指すため、エディターの端末やCIが違う版を使うことがよくあります。

Q. どう打ちますか。

node --version | node -v — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは5個です。全部は man node にあります。このコマンドはパッケージと実行環境の仲間です。

関連するコマンド

man ページ: man node---version