Open In App

Node.js process.version Property

Last Updated : 12 Oct, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The process.version property is an inbuilt application programming interface of the Process module which is used to check the node.js version.

Syntax:

process.version

Return: It returns a string signifying the version of the Node.js.

Below examples illustrate the use of process.version property in Node.js:

Example 1:




// Allocating process module
const process = require('process');
  
// Printing process.version
console.log("node.js version " + process.version);


Output:

node.js version v10.16.0

Example 2:




// Allocating process module
const process = require('process');
  
// Printing process.version
const ver = process.version;
console.log("node.js version " + ver);
  
// Printing version name
var name = "";
  
if(ver.startsWith('v10.')) {
        name = 'Dubnium';
}else if(ver.startsWith('v8.')) {
    name = 'Caron';
}else if(ver.startsWith('v6.')) {
    name = 'Boron';
}else if(ver.startsWith('v4.')) {
    name = 'Argon';
}else {
    name = 'unknown';
}
console.log("Node.js version name: " + name);


Output:

node.js version v10.16.0
Node.js version name: Dubnium

Reference: https://nodejs.org/api/process.html#process_process_version



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads