0
0
NodejsHow-ToBeginner · 3 min read

How to Check Node.js Version Quickly and Easily

To check your Node.js version, open your terminal or command prompt and run node -v or node --version. This command shows the installed Node.js version as a simple string.
📐

Syntax

The basic command to check Node.js version is node -v or node --version. Both commands do the same thing and print the version number of Node.js installed on your system.

  • node: The Node.js runtime command.
  • -v or --version: Flags to display the version.
bash
node -v
Output
v20.4.0
💻

Example

This example shows how to check the Node.js version from the terminal. Just type the command and press Enter. The output will be the version number.

bash
node -v
Output
v20.4.0
⚠️

Common Pitfalls

Sometimes users try to check the version inside a Node.js script incorrectly. For example, running console.log('node -v') just prints the string, not the version.

To get the version inside a script, use process.version.

javascript
console.log('node -v'); // Wrong way

console.log(process.version); // Right way
Output
node -v v20.4.0
📊

Quick Reference

Here is a quick summary of commands and code to check Node.js version:

bash
node -v
node --version

// In a Node.js script:
console.log(process.version);
Output
v20.4.0 v20.4.0 v20.4.0

Key Takeaways

Use node -v or node --version in the terminal to see Node.js version.
Inside a Node.js script, use process.version to get the version programmatically.
Both -v and --version flags work the same way.
Avoid printing version commands as strings inside scripts; use the proper API instead.