Display the runtime version in logs
Startup diagnostics
Node.js · Pipe
process.version is a string containing the version of the running Node.js runtime. It includes a leading v; use process.versions.node for the version without that prefix.
process.version is a read-only string containing the version of the Node.js runtime executing the program. It includes a leading v; use process.versions.node when that prefix is not wanted.
process.versionA string containing the Node.js version, with a prepended v.
version export from node:process.version from node:process.v0.1.3.v manually when you need an unprefixed version; use process.versions.node instead.console.log(`Version: ${process.version}`);
console.log(`Node-only version: ${process.versions.node}`);Prints the running Node.js version, then shows the equivalent version without the leading “v”.
Startup diagnostics
Compatibility checks
Version formatting
process.version contain?process.version is a string property on the global process object that reports the running Node.js version. Its value includes a leading v, such as v14.8.0.
Follow-up: How would you obtain the same version without the prefix? Use process.versions.node.
The property is read directly as process.version, or the named version export can be imported from node:process. Both represent the Node.js version string for the running process.
Follow-up: What module specifier should modern ESM code use for this import? Use the built-in node:process specifier.
process.version differ from process.versions.node?process.version identifies the Node.js runtime version, while process.versions.node provides the Node.js version string without the initial v. The latter is useful when a consumer expects an unprefixed value.
Follow-up: What should be used to inspect dependency versions too? Use the broader process.versions object, whose node entry is the Node.js version.
process.versionsprocess.versions.nodenode:process