Check Node and npm versions
Before running Node programs, identify the installed Node.js and npm versions. Node executes JavaScript; npm manages packages and scripts. Their version numbers are independent. For new work, select a currently supported patched LTS release from the official Node.js download and release pages rather than an arbitrary old installer.
Local practice: The proposed teaching runtime is Node.js 26.13.1 LTS. These original offline examples were executed on Node.js 22.16.0 (Linux x64); execution on the proposed baseline and in ByteMind is not yet verified. No npm dependencies are required. Use a fresh practice directory. Code blocks are static, not a browser-based Node runner.
Inspect the runtime version
In the directory containing the files above, run:
node --versionExpected standard output:
v22.16.0Expected exit status: 0.
How it works
node --version prints the runtime version. npm --version reports the package manager version. PATH is the operating system’s ordered list of directories used to find executable commands. If a command is not found, verify installation and which executable your terminal resolves; do not download and execute an unknown setup script. LTS means Long Term Support under the project release policy. A major release identifies a version line, not all patches in that line. The official release schedule and security notices should be consulted together. The v26 teaching candidate is 26.13.1; the older authoring runtime is not recommended as a deployed server.
Inspect selected public runtime version data
console.log(process.versions.node);console.log(process.versions.modules);In the directory containing the files above, run:
node main.mjsExpected standard output:
22.16.0127Expected exit status: 0.
Common mistake
The output above records the local authoring machine, not a required learner result. Other installed versions should print different numbers. Do not equate npm version, native module ABI number and Node major. Use the official installation instructions for your OS and architecture and verify signatures or checksums where applicable.
Try it yourself
Run node --version and npm --version locally if installed. Record both. Find the Node major and compare it with the official LTS schedule. If Node is unavailable, inspect the displayed sample version without installing anything automatically.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Check Node and npm versions — knowledge check
Check your understanding of check node and npm versions.
What does `node --version` identify?
Why prefer a patched supported release?
What should you conclude if npm and Node report different major versions?