Wednesday, March 11, 2020

How to check v8 engine version of installed nodejs environment

Nodejs is a popular javascript runtime environment that internally uses the V8 engine.
How to check v8 engine version of installed nodejs environment
Every year javascript releases new features, To use those new features into nodejs project, We have to use either babel plugins or v8 engine version that supports the new javascript features into it. Developers usually check the versions for Nodejs and V8 environment whether the latest javascript features available or not.

This post talks about different ways to list the V8 version of Nodejs Environment. Nodejs comes with node and npm command-line tools.

How to check the Node and npm tools version?

D:\>node --version
v12.14.1

D:\>npm --version
6.13.4

Find v8 engine version of installed nodejs environment 

nodejs ships with different binary dependent versions, v8 is one of the components. using npm version command list outs all dependent components version as follows
D:\>npm version
{
  npm: '6.13.4',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  llhttp: '2.0.1',
  modules: '72',
  napi: '5',
  nghttp2: '1.40.0',
  node: '12.14.1',
  openssl: '1.1.1d',
  tz: '2019c',
  unicode: '12.1',
  uv: '1.33.1',
  v8: '7.7.299.13-node.16',
  zlib: '1.2.11'
}
Another way is using node -pe command option
D:\>node -pe process.versions
{
  node: '12.14.1',
  v8: '7.7.299.13-node.16',
  uv: '1.33.1',
  zlib: '1.2.11',
  brotli: '1.0.7',
  ares: '1.15.0',
  modules: '72',
  nghttp2: '1.40.0',
  napi: '5',
  llhttp: '2.0.1',
  http_parser: '2.8.0',
  openssl: '1.1.1d',
  cldr: '35.1',
  icu: '64.2',
  tz: '2019c',
  unicode: '12.1'
}
All this dependent binary versions meta information is stored in the process global object. To get the v8 version with the node command
D:\>node -p process.versions.v8
7.7.299.13-node.16

Using REPL command

 REPL is the command-line testing environment to test the nodejs features in the command line. type node command
D:\>node
Welcome to Node.js v12.14.1.
Type ".help" for more information.
>                                     
Type process.versions.v8 text in prompt
D:\>node
Welcome to Node.js v12.14.1.
Type ".help" for more information.
> '                                                                                                                                                                     
'7.7.299.13-node.16'

Related article


EmoticonEmoticon