Whether you're a developer setting up a new project, troubleshooting compatibility issues, or just ensuring the development environment is up-to-date, knowing the Node.js version is an important step. Different projects or dependencies often require specific versions of Node.js, and having this information at your fingertips can save you time. This tutorial explains how to check Node.js version.
1. 'version' option
The easiest and most common way to check the Node.js version is by using the command line option version
(or the -v
shortcut):
node --version
node -v
Output example:
v20.6.1
2. 'process.version' property
Within the Node.js application, you can use the process.version
property:
const version = process.version;
console.log(version);
3. 'process.versions.node' property
Another way to fetch the Node.js version programmatically is through the process.versions.node
property. It specifically returns the Node.js version without the leading "v".
const version = process.versions.node;
console.log(version);
Leave a Comment
Cancel reply