Multiple ways to get NodeJS version with examples

This tutorial shows multiple ways to know the installed node and npm version. You can also check other posts on npm command deprecate option is deprecated

How to get Node and npm versions in the command line

Open the terminal, type below command node --version or node -v

C:\>node --version

node —version gives nodejs version installation number.

If you got the below error, node: command not found without a print version number, Then the probable cause is that nodejs is installed with the correct version or node path is not correctly set in environment variables.

-bash: node: command not found

And,npm is a node package manager that installs automatically with nodejs installation Run the below command to get the npm version.

C:\>npm --version
C:\>npm -v

Another way is to get the node version in javascript programming.

A process is a global object in Nodejs, versions property returns an object of versions

Create a main.js


Running node main.js output below versions It contains node attribute with version

node: '14.17.0',
v8: '8.4.371.23-node.63',
uv: '1.41.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.17.1',
modules: '83',
nghttp2: '1.42.0',
napi: '8',
llhttp: '2.1.3',
openssl: '1.1.1k',
cldr: '38.1',
icu: '68.2',
tz: '2020d',
unicode: '13.0'

Another property process.version gives the node version


Similarly, you can get the node version using the command line with REPL. REPL is Read-Eval-Print-Loop interactive terminal to get nodejs process and execute node commands

Type node in terminal to change to REPL mode


Type process.versions in the terminal



Learned multiple ways to get node npm version using javascript code and interactive REPL terminal.