How to check the current Node.js version at runtime

runprocess.version:

ThisversionAttribute ofprocessThe object returns the string of the current Node.js version.

In the browserprocessThe object is not defined, so you will get a ReferenceError:

Another way is to refer toprocess.versions(plural):

This will return an object containing various properties that refer to each component version.

Get the major version (in this example12) you can use it

process.versions.node.split('.')[0]

Download mine for freeNode.js manual


More node tutorials: